Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
2.33/5 (2 votes)
See more: , +
Hi,

How do I match the below two thank you pages?

First thank you page: "mydomain.com/paid/49549/"

I want the trigger it only when "paid" is the first file after after the domain name because "paid" sometimes is added to other pages in the middle or at the end and the "49549" is dynamic folder/parameter

2nd thank you page: "/hello/DYNAMICstring/geek/1619/paid/"

so "hello" & "geek" & "paid" are the only static folders while "DYNAMICstring" & "1619" are dynamic folders.

Thank you so much
Posted

1 solution

For the regular expression part you can start to look here at MDN: JavaScript Regular Expressions[^] (If JavaScript is the language)
And also here Regular Expression Info[^]

It is also useful to have a tool where you can test expressions in a visual way. I use this application myself RegexTest[^], but there are others as well, including online tools.

If I understand you correctly, you want to match
mydomain.com/paid/49549/

but not
/hello/DYNAMICstring/geek/1619/paid/

If that is the case, this expression will do the trick:
^\S+?/paid

It basically means it will match any character before the first / in the string and then paid has to follow.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900