Page 1 of 1

Understanding RegExps

Posted: Mon Aug 16, 2004 3:42 am
by visionmaster
Hello,

I just made the experience that RegExps are WORN (write once, read never). I actually got help in this forum for the following RegExps, but unfortunately can not "read" them anymore. Can anybody give me a detailed, step by step description of the RegExps, so I really can understand the pattern?

preg_match_all('#^descr:\s*(.*?)\s*$#m', $array[3], $matches);

preg_match('#^\s*([^\s]+?)\s+(.*?)\s*$#s', $array[3], $matches);


Thanks a lot,
visionmaster

Posted: Mon Aug 16, 2004 3:49 am
by feyd
1. find all lines that start with the string 'descr:' followed by any number of spaces, remember all characters outside of trailing spaces until the end of the line.

2. remember the first word (excluding leading spaces), remember the following until the end of the string (excluding leading and trailing spaces)

Posted: Mon Aug 16, 2004 6:07 am
by visionmaster
O.k., I think I got it. The only thing that still confuses me is (.*?)

Thanks

Posted: Mon Aug 16, 2004 6:19 am
by vigge89
visionmaster wrote:O.k., I think I got it. The only thing that still confuses me is (.*?)

Thanks
I think that (.*?) is what the script forwards, ie, what you are looking for.
That's probably all I know about RegExps :P