[pmwiki-devel] regex question

Patrick R. Michaud pmichaud at pobox.com
Wed Aug 26 12:48:17 CDT 2009


On Wed, Aug 26, 2009 at 06:07:02PM +0100, Hans wrote:
> I need a regex which finds text with open [@ markup bracket
> in a text string.
> It should match for instance
>   abcd123[@xyz
> but not
>   abcd123[@xyz@]
> Basically I want to remove open [@ character pairs from a text line.
> 
> Can someone help please?

    /\[@(?!.*@\])/

Broken down:
    /   \[@  (?! .* @\]  )  /

The first part finds [@.  The (?!...) is a negative lookahead.
The .*  and @\]  look for any subsequent @].

Pm



More information about the pmwiki-devel mailing list