I have a challenge with a regex match to a url I hope I can bug some of you clever heads with :-)
Please take a look at this testcase https://www.regex101.com/r/bH4hE1/2
I use the regex: (\w+)(.\w+)+(?!.*(\w+)(.\w+)+)
Problem is, it only finds reports.html but I also need to find reports in the first url
https://my.website.com/reports?ref_=kdp_BS
https://my.website.com/reports.html
To capture "reports" or "reports.html" in any path, begin your match after the last /, and capture word characters and .:
/.*\/([.\w+]+)/
See: https://www.regex101.com/r/iZ7dF3/8
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With