REGEX question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?ISO-8859-1?Q?Feij=F3?=

    REGEX question

    I'm very new to Regex, I've been strugling a lot to use it, hard to
    find good material :)

    I just need to find all matchs for something like this:
    D00:00:00:00

    leter D, following by 4 sequences of 2 digits separated by : (2
    points)

    How can I do that?

    There is any software for windows that helps us newbies learn that
    fabulous language?


    Thanks!!
    Feijó
  • Tim Roberts

    #2
    Re: REGEX question

    Feijó <afeijo@gmail.c omwrote:
    >
    >I'm very new to Regex, I've been strugling a lot to use it, hard to
    >find good material :)
    >
    >I just need to find all matchs for something like this:
    D00:00:00:00
    >
    >leter D, following by 4 sequences of 2 digits separated by : (2
    >points)
    >
    >How can I do that?
    "D[0-9]{2}:[0-9]{2}:[0-9]{2}:[0-9]{2}"
    --
    Tim Roberts, timr@probo.com
    Providenza & Boekelheide, Inc.

    Comment

    • Rik Wasmus

      #3
      Re: REGEX question

      On Fri, 07 Mar 2008 03:39:26 +0100, Feijó <afeijo@gmail.c omwrote:
      There is any software for windows that helps us newbies learn that
      fabulous language?
      At Regular-Expressions.info you will find a wide range of in-depth information about a powerful search pattern language called regular expressions.


      A while back I used the .Net Regex Workbench. Can't seem to find a place
      to download it from now though...
      --
      Rik Wasmus

      Comment

      • =?ISO-8859-1?Q?Feij=F3?=

        #4
        Re: REGEX question

        Him Tim, Thanks!

        Thats wierd, your code works on my pspad regex search (if found a
        example I type in my source-code), but when I run over php, this error
        is returned:

        Warning: preg_match_all( ) [function.preg-match-all]: Delimiter must
        not be alphanumeric or backslash

        You know why?


        On Mar 7, 3:52 am, Tim Roberts <t...@probo.com wrote:
        Feijó <afe...@gmail.c omwrote:
        >
        I'm very new to Regex, I've been strugling a lot to use it, hard to
        find good material :)
        >
        I just need to find all matchs for something like this:
        D00:00:00:00
        >
        leter D, following by 4 sequences of 2 digits separated by : (2
        points)
        >
        How can I do that?
        >
        "D[0-9]{2}:[0-9]{2}:[0-9]{2}:[0-9]{2}"
        --
        Tim Roberts, t...@probo.com
        Providenza & Boekelheide, Inc.

        Comment

        • Rik Wasmus

          #5
          Re: REGEX question

          On Fri, 07 Mar 2008 11:33:00 +0100, Feijó <afeijo@gmail.c omwrote:
          On Mar 7, 3:52 am, Tim Roberts <t...@probo.com wrote:
          >Feijó <afe...@gmail.c omwrote:
          >>
          >I'm very new to Regex, I've been strugling a lot to use it, hard to
          >find good material :)
          >>
          >I just need to find all matchs for something like this:
          D00:00:00:00
          >>
          >leter D, following by 4 sequences of 2 digits separated by : (2
          >points)
          >>
          >How can I do that?
          >>
          >"D[0-9]{2}:[0-9]{2}:[0-9]{2}:[0-9]{2}"
          >
          Thats wierd, your code works on my pspad regex search (if found a
          example I type in my source-code), but when I run over php, this error
          is returned:
          >
          Warning: preg_match_all( ) [function.preg-match-all]: Delimiter must
          not be alphanumeric or backslash
          If you use the preg_* family, you have to use delimiters (any
          non-alphanumeric character that's not the backslash) to surround your
          pattern, so you can put modifiers behind the ending delimiter if you like.
          '/' is the most commonly used.

          preg_match_all( '/D[0-9]{2}:[0-9]{2}:[0-9]{2}:[0-9]{2}/',$string,$matc hes);
          --
          Rik Wasmus

          Comment

          • Tim Roberts

            #6
            Re: REGEX question

            Feijó <afeijo@gmail.c omwrote:
            >
            >Him Tim, Thanks!
            >
            >Thats wierd, your code works on my pspad regex search (if found a
            >example I type in my source-code), but when I run over php, this error
            >is returned:
            >
            >Warning: preg_match_all( ) [function.preg-match-all]: Delimiter must
            >not be alphanumeric or backslash
            >
            >You know why?
            Rik posted the answer to this, but I'd like to take this opportunity to put
            in a recommendation for an excellent and somewhat underappreciate d book:
            Jeffrey Friedl's "Mastering Regular Expressions".

            I got the book originally on a whim, thinking "what could he possibly have
            to say about regular expressions that would take a whole book", but I find
            that I have referred to it again and again. It is an excellent and
            thorough treatise on the subject. The third edition even includes a
            45-page chapter on PHP.

            And as a bonus, he includes a regular expression that matches every legal
            RFC 822 email address. It is several tens of thousands of characters long.
            --
            Tim Roberts, timr@probo.com
            Providenza & Boekelheide, Inc.

            Comment

            • John Dunlop

              #7
              Re: REGEX question

              Tim Roberts:
              And as a bonus, he includes a regular expression that matches every legal
              RFC 822 email address. It is several tens of thousands of characters long.
              ....much to your consternation if you don't have OCR!!

              --
              Jock

              Comment

              Working...