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.