Reputation: 2932
I would like to detect all these url's with a regular expression:
/liga-femenina-1
/liga-femenina-1/equipos
/liga-femenina-1/resultados
/liga-femenina-1/estadisticas
/liga-femenina-1/buscador
/liga-femenina-2
/liga-femenina-2/equipos
/liga-femenina-2/resultados
/liga-femenina-2/estadisticas
/liga-femenina-2/buscador
I have defined this regular expression:
\/liga-femenina-(1|2)\/?\w*
This regular expression only detects the first url.
But, If I remove the first url, the regular expression detects correctly the next url when before doesn't do it.
How can I make that my regular expression detects all the urls? What am I doing wrong?
Upvotes: 0
Views: 46
Reputation: 68933
Try with flag g (global):
/\/liga-femenina-(1|2)\/?\w*/g
g
global match; find all matches rather than stopping after the first match
Please Note: If you use start and end in the regex then use flag m
(multiline):
/^\/liga-femenina-(1|2)\/?\w*+$/gm
m
multiline; treat beginning and end characters (^ and $) as working over multiple lines (i.e., match the beginning or end of each line (delimited by \n or \r), not only the very beginning or end of the whole input string)
Upvotes: 4