Reputation: 55
I have an URI like
myurl-c-10_550_05.html
I would like to match any URI containing the exact number 10 anywhere , like :
myurl-c-10_550_05.html
myurl-c-550_10_05.html
myurl-c-550_05_10.html
myurl-c-550_10.html
myurl-c-10.html
but not 100 or 1000 like
myurl-c-100_550_05.html << Wrong
What I tried and working for the figure 10 or 100 or 1000 is :
preg_match("/-c-(?:[0-9_]+|)(10)(?:[0-9_]+|)/",$baseuri)
But I can't get the fixed 10 figure even whith this other regex :
preg_match("/-c-(?:[0-9_]+|)(^10$)(?:[0-9_]+|)/",$baseuri)
I've spent nearly 2 hours on stackoverflow , reading a lot, trying a lot with this cool tool :
EDITED : this regex should also check there is a -c- in the uri followed by some digits and undersocre or not and ending with a point.
not working : myurl-i-10_gasp.html
Can someone help me ? Thanks !
Sebastien
Upvotes: 0
Views: 144
Reputation: 55
The solution with the help of Toto :
-c-(?:[0-9_]+|)(?<!\d)10(?!\d)
You can see it working here: https://regexr.com/4eit3
Upvotes: 0