[ and ] are metacharacters in RegExp patterns. For example, "[abc]"
matches either "a", or 'b" or "c". To prevent this interpretation,
escape them with a backslash.

 

Gordon Smith

Adobe Flex SDK Team

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Derrick Anderson
Sent: Tuesday, April 15, 2008 12:49 PM
To: [email protected]
Subject: [flexcoders] RegExp searching for [ and ], are they reserved?

 

hey all,

i'm trying to do a replace on a string and replace anything in brackets
with something else.

so [this] word would get replaced, however in the regex tester at
gskinner this works fine (it's flex based regex test tool) but in my
local code- i always get unexpected results when my regex expression has
brackets in it.

private var mergeRE:RegExp = new RegExp("\[[^>]*?]","igm");

is there another escape character i need to use, why does flash have a
problem searching for [ and ] in regex?

thanks,
d.

 

Reply via email to