I’m attempting to do a find and replace using regular expressions and grabbing the first (and only in this case) backreference as a variable.
var RegexSearchString = "/((?:^(?:https?://|www\\d{0,3}[.])(?:.*?/)|(?:[a-z0-9.\\-]+[.][a-z]{2,4}/))(?:.*?/))/";
var test = "http://foo.bar.net/interestingbit/lots/of/other/stuff/here";
alert(test);
test.replace(umassURLRegexSearchString, "$1");
alert(test);
The expected result should be an alert with:
http://foo.bar.net/interestingbit/lots/of/other/stuff/here
followed by an alert with:
http://foo.bar.net/interestingbit/
Both alerts contain the value of the test variable as first initialized. Any ideas as to where this is breaking down?
You need to:
The code with all of these changes is:
Check it out here: http://jsfiddle.net/jheHR/1/