[pmwiki-users] pattern matching:
Patrick R. Michaud
pmichaud at pobox.com
Mon Dec 4 12:04:59 CST 2006
On Mon, Dec 04, 2006 at 09:56:42AM -0800, Martin Fick wrote:
> --- "Patrick R. Michaud" <pmichaud at pobox.com> wrote:
> > On Sat, Dec 02, 2006 at 08:15:44PM -0500, The Editor
> > wrote:
> > > I'm trying to get this to match expressions like
> > > the following:
> > >
> > > {TEXT:Group.Name-36_End}
> > >
> >
> > Keep it simple:
> >
> > preg_replace('/\\{([-.:\\w]+)\\}/e', "Function('$1')", $text)
>
> I think:
>
> preg_replace('/\\{([_-.:\\w]+)\\}/e', "Function('$1')", $text)
My original is correct.
- If a hyphen is to be one of the characters matched, it has to
be escaped or at the beginning/end of the set.
- \w includes underscores, so there's no need to repeat it in
the list (although it doesn't hurt much to do so).
Pm
More information about the pmwiki-users
mailing list