Reputation: 57
I need to match with preg_match the urls of a certain domain that end on .co but not match those who end on .com
example:
www.cool.com
www.cool.com.co [MATCH]
www.cool.co [MATCH]
I was trying to use the expression [\.co]{3}
but it matches me all the URLs (www.co
ol.co
m.co
)
Thanks in advance for the help ;-)
[EDIT]
URLs like www.cool.co/coolness
should also be a match
Upvotes: 0
Views: 118
Reputation: 57
Finally did it!
The regexp was: /\b\.(co)\b/g
www.cool.com
cool.com
www.cool.com.co [MATCH]
cool.com.co [MATCH]
www.cool.com/coolness
cool.com/coolness
www.cool.com.co/coolness [MATCH]
cool.com.co/coolness [MATCH]
Upvotes: 0
Reputation: 18064
Try this Regex
/((.*)(.co))$/gm
See this DEMO
/((.*)(.co)($|/)(.*))/gm
See this DEMO 2
Upvotes: 1