Reputation: 625
I really don't get it, probably I will never understand regex. Sorry!
If I have a string like
/0123456789.html
I want to excerpt the number. The length has 8-10 digits. With
\/[0-9]{8,10}(?:.html)
I get the whole part, but I just want the period of numbers (here 0123456789).
Upvotes: 0
Views: 66
Reputation: 12880
You can use the RegEx (?<=\/)\d{8,10}(?=\.html)
(?<=\/)
makes sure there is a /
before your match
\d{8,10}
matches a digit between 8 and 10 times
(?=\.html)
makes sure your match is followed by .html
Upvotes: 1