Regular Expression Help - How do I match a format?

loopline

Elite Member
Jr. Executive VIP
Jr. VIP
Joined
Jan 25, 2009
Messages
6,378
Reaction score
3,774
Hey all, I know enough about regular expressions to be dangerous. I would like to match this format:
Code:
broadway-basketeers-deluxe-chocolate-and-nut-collection-gourmet-snack-gift-basket
I don't want to match the words exactly, but what I want to match is words with dashes inbetween.

So basically

xxxx-xxxx-xxxx-xxxx-xxxx


To see if I can make it more complex here the words could be anything, and any length, so

xx-xxxxxxx-xxxxx

or

xxxxx-xxxxxxxxxxx-xx-xxxxxxxx-xxxxxxxxx

etc...

How do I do this effectively?

At least it would be two words with a dash, at most probably 16 words with dashes between.

Allowing for numbers in addtion to words would be ideal.


Also anything that ends with .html I don't want.

So

xxxx-xxxxx-xxxxx-xxxxxxxxx.html

I don't want that, I only want it if its just words and dashes.

I am trying to build an url filter.

Any ideas on how I could do this?

Thanks in advance for your time.
 
Last edited:
Someone figured it out for me. If anyone else is in need of it, here it is:

([a-z0-9-]+)
 
Back
Top