Jump to content

Regex - targeting urls with dashes only?


Frosty

Recommended Posts

I'm hoping to finish a regex that I've been trying to craft, and would like some advice as I've hit a roadblock .

 

 

So I have a whole list of urls. I need to only capture 'seo friendly' (typically article/post titles) urls with at least one dash, like:

http://thepigeonnest.com:80/passenger-pigeons-ectopistes-migratorius/
http://thepigeonnest.com/pigeon-lover-mike-tyson-to-star-in-pigeon-reality-show/

But, my regex also captures sub-folders without a dash like:

http://pinkstripedpig.com/contact/

My regex so far is thus:

http://([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}(/|:80/)[a-z0-9-]+/
Link to comment
https://forums.phpfreaks.com/topic/283822-regex-targeting-urls-with-dashes-only/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.