A little regex help?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ivan Marsh

    A little regex help?

    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

    #2
    Re: A little regex help?

    On Mar 27, 12:33 pm, Ivan Marsh <anno...@you.no wwrote:
    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.
    Perl regex, regular expression, extracting information, text processing


    Comment

    • scripts.contact

      #3
      Re: A little regex help?

      On Mar 27, 10:33 am, Ivan Marsh <anno...@you.no wwrote:
      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\.c om/i


      Comment

      • anthony

        #4
        Re: A little regex help?

        scripts.contact wrote:
        On Mar 27, 10:33 am, Ivan Marsh <anno...@you.no wwrote:
        >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\.c om/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:


        Comment

        Working...