This is a discussion on REGEX question within the PHP Language forums, part of the PHP Programming Forums category; I'm very new to Regex, I've been strugling a lot to use it, hard to find good material :) ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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ó |
|
|||
|
Feijó <afeijo@gmail.com> wrote:
> >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. |
|
|||
|
On Fri, 07 Mar 2008 03:39:26 +0100, Feijó <afeijo@gmail.com> wrote:
> There is any software for windows that helps us newbies learn that > fabulous language? http://www.regular-expressions.info/ A while back I used the .Net Regex Workbench. Can't seem to find a place to download it from now though... -- Rik Wasmus |
|
|||
|
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.com> wrote: > > >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. |
|
|||
|
On Fri, 07 Mar 2008 11:33:00 +0100, Feijó <afeijo@gmail.com> wrote:
> On Mar 7, 3:52 am, Tim Roberts <t...@probo.com> wrote: >> Feijó <afe...@gmail.com> wrote: >> >> >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,$matches); -- Rik Wasmus |
|
|||
|
Feijó <afeijo@gmail.com> wrote:
> >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 underappreciated 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. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|