[pmwiki-devel] Quick preg_replace question...
Patrick R. Michaud
pmichaud at pobox.com
Fri Apr 27 12:39:06 CDT 2007
On Fri, Apr 27, 2007 at 12:11:56PM -0400, The Editor wrote:
> >It's probably also a good idea to put a \b after [trc], so that
> >the markup engine won't inadvertently think that [citation]
> >is to be treated the same as [c].
> >
> > '/(\n?)\[([trc]\\b)(.*?)\]/e'
>
> \b will work whether the next character is a space or a ] ? (the only
> two possibilities I'm concerned about...
\b matches if the previous character is alphanumeric and the
following one is not, or vice-versa. In this case, it makes
certain that whatever follows the 't', 'r', or 'c' is not
a letter or digit.
> And to get it so it could take t1 or r3 could I do
>
> '/(\n?)\[([trc][0-9]{0,1}\\b)(.*?)\]/e'
Shorter:
/(\n?)\[([trc]\d?\\b)(.*?)\]/
Pm
More information about the pmwiki-devel
mailing list