Reputation: 2567
Hello I have a string with some path. It looks like .../my/test/....
, I want to mutch all string where exists /my/test/
. But I am newbie in RegEpx and dont know how I can do this? I need to escape /
? I try something like this:
\"[^/"]+/my/test/+[/$]
but wont work (and I think cant work). Can somebody help me please?
Upvotes: 0
Views: 71
Reputation: 67968
^.*?\/my\/test\/.*$
You can simply do this.See demo.
https://regex101.com/r/wU7sQ0/26
var re = /^.*?\/my\/test\/.*$/gm;
var str = 'asdd/as/d/as/dasdas/my/test/asdasd/s/a/dsa/\nasdd/as/d/as/dasdas/my/notest/asdasd/s/a/dsa/';
var m;
while ((m = re.exec(str)) != null) {
if (m.index === re.lastIndex) {
re.lastIndex++;
}
// View your result using the m-variable.
// eg m[0] etc.
}
Upvotes: 1
Reputation: 3774
you can escape '/' by using '/' your expression can be something like /my/test//g
explanation of the expression + reference of regex is here: https://regex101.com/r/cG5aA3/1
Upvotes: 1