When using a regex like this:
I am attempting to replace "subdir" with a custom string using the string.replace method.
However, when I use
myStr.replace(/^.*\/\/.*\.net\/.*\/(.*)\/.*\z/, otherStr)
The result is not as expected, you can see it here: http://jsfiddle.net/nLmbV/
The Rublar tool seems to capture what I want correctly, but the Fiddle fails to replace it.
I would like to understand why this discrepancy occurs and identify any mistakes in my approach. While corrections in the regex or replace call are welcome, understanding where I went wrong is most important for future reference.
EDIT
I have updated the fiddle by changing my regex from:
/^.*\/\/.*\.net\/.*\/(.*)\/.*\z/
To:
/^.*\/\/.*\.net\/.*\/(.*)\/.*$/
Yet, the fiddle now returns only hello
instead of
https://xxxxxxxxxxx.cloudfront.net/dir/hello/Slide1_v2.PNG