You are here: Re: delimited by different characters? « PHP Language « IT news, forums, messages
Re: delimited by different characters?

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/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация