Admit that I suck in writing regular expression. Please help me to solve how to write regular expression for success-apply founded in URL just like http://www.example.com/success-apply/
2 Answers
Assuming that the pattern success-apply changes:
example\.com\/([^\/]+)
# capture everything that is not a forward slash one or unlimited times
Here is this regex example with PCRE (PHP).
If you however only want to know if the string is there at all, regular expressions seem a bit of an overkill. Consider the following PHP code:
if (strpos($url, 'success-apply') !== FALSE) {
// do sth useful
}
Comments
Is this what you are looking for?
(success-apply)
2 Comments
Enrique Quero
I think this answer is incorrect... because you are not finding the match sucess-apply in an url... you re finding in the entire text, whatever it is
Chief Wiggum
You mean I'm not checking if it's a valid url before I'm searching for the keyword? I don't think this is what the OP is asking for. He has a list of urls (I assume), wether they are valid or not is in this case not the question, but if these strings contain the keywords or not.
success-applyis included in URL string or not.