I'm confused... why isn't your pattern something like "\[.*]\]" ? What's going on with the ^ and the > ? What is supposed to match against letters like E, m, p, l, etc.?
Gordon Smith Adobe Flex SDK Team ________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Derrick Anderson Sent: Tuesday, April 15, 2008 1:23 PM To: [email protected] Subject: Re: [flexcoders] RegExp searching for [ and ], are they reserved? i had tried escaping them, below i've pasted an example of my problem- 2 samples: 1 looking for [Employee First Name] and one looking for {Employee First Name} (curly braces vs square braces) and even though the brackets are escaped, the regex with [ and ] only return the ending ]. do i have the regex wrong? <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml> " layout="absolute"> <mx:Script> <![CDATA[ private var mergeRE:RegExp = new RegExp("\[[^>]*?\]","igm"); private var mergeRE2:RegExp = new RegExp("{[^>]*?}","igm"); public function runSquareBracketTest():void { var response:Array = subjectString.text.match(mergeRE); resultString.text = response.toString(); } public function runCurlyBracketTest():void { var response:Array = subjectString.text.match(mergeRE2); resultString.text = response.toString(); } ]]> </mx:Script> <mx:VBox> <mx:TextArea id="subjectString" width="400" height="200"> <mx:text> <![CDATA[<strong>[Employee First Name] </strong> <strong>{Employee Last Name} </strong>]]> </mx:text> </mx:TextArea> <mx:TextArea id="resultString" width="400" height="200" /> <mx:Button click="runSquareBracketTest();" label="Get first name." /> <mx:Button click="runCurlyBracketTest();" label="Get last name." /> </mx:VBox> </mx:Application> On Tue, Apr 15, 2008 at 4:08 PM, Gordon Smith <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> > wrote: [ 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]> [mailto:[email protected] <mailto:[email protected]> ] On Behalf Of Derrick Anderson Sent: Tuesday, April 15, 2008 12:49 PM To: [email protected] <mailto:[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.

