[pmwiki-devel] Quick preg_replace question...

The Editor editor at fast.st
Fri Apr 27 11:11:56 CDT 2007


On 4/27/07, Patrick R. Michaud <pmichaud at pobox.com> wrote:
> On Fri, Apr 27, 2007 at 11:56:12AM -0400, The Editor wrote:
> > I'm out of time to test this now but will look into it...  Maybe:
> >
> > '/([\n]{0,1})\[([trc]{1})(.*?)\]/e'
>
> Just a note that [\n]{0,1} is written shorter (and faster) as \n? .
>
>   '/(\n?)\[([trc])(.*?)\]/e'
>
> 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'
>
> Pm


\b will work whether the next character is a space or a ] ?  (the only
two possibilities I'm concerned about...

And to get it so it could take t1 or r3 could I do

'/(\n?)\[([trc][0-9]{0,1}\\b)(.*?)\]/e'

Thanks again for your help with these bewildering patterns.  Though
they are beginning to make a bit of sense at least...

Cheers,
Dan



More information about the pmwiki-devel mailing list