Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

(elbie): regex for but not \\

by elbie (Deacon)
on May 27, 2002 at 01:00 UTC ( #169456=note: print w/ replies, xml ) Need Help??


in reply to regex for [ but not \[

Look ahead and look behind assertions are perfect for this sort of thing. In this case, negative assertions can make sure that the extra pattern you specify (i.e. the backslash) doesn't occur:

m/(?<!\\)\[.*?\](?!\\)/g should do what you want.

Update: jeffa pointed out my .?* should in fact be a .*?

elbieelbieelbie


Comment on (elbie): regex for but not \\
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://169456]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2015-08-30 20:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...













    Results (351 votes), past polls