[pmwiki-users] pattern matching:
J. Meijer
commentgg at hotmail.com
Sun Dec 3 07:55:09 CST 2006
On 12/2/06, The Editor <editor at fast.st> wrote:
I'm working on a "special" project and trying to get this pattern
match to work and it almost works, but I seem to be having some
problems with :, -, and . in the [ ].
preg_replace('|\{([\-\.A-Za-z0-9:_]+)\}|e', "Function($1)", $text);
I'm trying to get this to match expressions like the following:
{TEXT:Group.Name-36_End}
Any help would be appreciated.
Cheers,
Caveman
----------
Hi Caveman,
I'm not at my desk, so I'm unable to test the following.
The problem with your regex seems to be with delimiters: I don't think the pipe | symbol is allowed to be used. It's used within regexes. Furthermore, you don't need to escape anything but the delimiters inside a regex. That includes the charset ] end-delimiter. You did place the '-' at the start so it doesn't get interpreted as a a-z range.
Your regex becomes simpler:
preg_replace('!\{([-.A-Za-z0-9:_]+)\}!e', "Function($1)", $text);
Hopefully this'll get you going again.
ps Do you really want such a free form regex?? You'd normally want to decompose into elements.. and so strictly match each element.
/jm
_________________________________________________________________
All-in-one security and maintenance for your PC. Get a free 90-day trial!
http://www.windowsonecare.com/purchase/trial.aspx?sc_cid=wl_wlmail
More information about the pmwiki-users
mailing list