For Programmers: Free Programming Magazines  


Home > Archive > PHP Programming > March 2007 > A little regex help?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author A little regex help?
Ivan Marsh

2007-03-27, 7:00 pm

Man I suck at regex.

How do I write a regex that matches http://att.com and http://www.att.com
but doesn't match http://matt.com or http://www.bratt.com?

I'm trying to create a whitelist but I keep ending up with sites I don't
want matching my criteria.

I just can't seem to get my head around it.

Any help would be appreciated.
Aaron

2007-03-27, 7:00 pm

On Mar 27, 12:33 pm, Ivan Marsh <anno...@you.now> wrote:
> Man I suck at regex.
>
> How do I write a regex that matcheshttp://att.comandhttp://www.att.com
> but doesn't matchhttp://matt.comorhttp://www.bratt.com?
>
> I'm trying to create a whitelist but I keep ending up with sites I don't
> want matching my criteria.
>
> I just can't seem to get my head around it.
>
> Any help would be appreciated.


check out the following site. It helped me out a lot.
http://www.anaesthetist.com/mnm/perl/regex.htm

scripts.contact

2007-03-27, 7:00 pm

On Mar 27, 10:33 am, Ivan Marsh <anno...@you.now> wrote:
> Man I suck at regex.
>
> How do I write a regex that matches http://att.com and http://www.att.com
> but doesn't match http://matt.com or http://www.bratt.com ?



/^http:\/\/(w{3}\.)?att\.com/i


anthony

2007-03-30, 7:59 am

scripts.contact wrote:
> On Mar 27, 10:33 am, Ivan Marsh <anno...@you.now> wrote:
>
>
> /^http:\/\/(w{3}\.)?att\.com/i


I highly recommend the following app, it helped me a lot in allowing to
paste in text and then check regex expressions against the text quickly:

http://weitz.de/regex-coach/
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com