Last active
October 11, 2017 15:44
-
-
Save aflansburg/8b2c8d1b8ca3dd7d1afb428c9abc07f4 to your computer and use it in GitHub Desktop.
RC strip img uri from full url
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const regex = /^(.*product)\/cache.*(\/[a-z]\/[a-z]\/.*)/g; | |
let testUri = window.prompt('Input the full image url to be cleaned:'); | |
let m; | |
let uriArr = []; | |
let cleanUri; | |
while ((m = regex.exec(testUri)) !== null) { | |
if (m.index === regex.lastIndex) { | |
regex.lastIndex++; | |
} | |
uriArr.push(m[1]); | |
uriArr.push(m[2]); | |
cleanUri = uriArr.join(''); | |
console.log(cleanUri); | |
window.prompt('CTRL+C/CMD+C to copy', cleanUri); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment