7
rated 0 times
[
12]
[
5]
/ answers: 1 / hits: 88037
/ 14 Years ago, wed, january 12, 2011, 12:00:00
Do i have to escape slashes when putting them into regular expression?
myString = '/courses/test/user';
myString.replace(//courses/([^/]*)/.*/, $1);
document.write(myString);
Instead of printing test, it prints the whole source string.
See this demo:
http://jsbin.com/esaro3/2/edit
More From » regex