Posted by Philip Ronan on 10/25/05 18:02
"Dummy Newgroup name" wrote:
> Thank you.
> Not having a Perl background I've always been daunted by the regular
> expression stuff.
> Thanks to you I've now found the section in the php manual and will
> not take fright so easily.
>
> Thank you again.
> Mark
>
> <A bit later> B*gg*r! It's a nightmare 8-( More diligence reqd,
> gulp!
Hang in there -- it isn't really *that* difficult :-)
I spotted a mistake in my last post -- try replacing "preg_match" with
"preg_match_all". The regular expression /\[([^\]]+)\]/ works like this:
/ - marks the start of the pattern
\[ - matches a "[" character (escaped with a backslash)
( - marks the beginning of the text we want to extract
[^\]] - matches any character that isn't "]" (escaped with a backslash)
+ - match the previous pattern 1 or more times
) - end of text to extract
\] - matches a "]" character
/ - marks the end of the pattern
The backslashes are necessary because "[" and "]" have a special meaning in
regular expressions (i.e., specifying a range of characters to match)
--
phil [dot] ronan @ virgin [dot] net
http://vzone.virgin.net/phil.ronan/
[Back to original message]
|