Matching Parentheses with Regex in Flex
For some reason I can't seem to match a parentheses in Flex using Regex to save my life.
What's wrong with this?
var 开发者_如何学CcommandTxt:String = "switchview(adf)";
var switchViewArray:Array = commandTxt.match(new RegExp("switchview\(", "i"));
I've tried dozens of things, but I can't seem to get a match the parentheses. What's the catch here?
I never used Flex, but most likely this is because the \
has a special meaning in double quotes.
Use a double-escape:
new RegExp("switchview\\(", "i");
Or you can also write:
var pattern:RegExp = /switchview\(/i;
... match(pattern)
精彩评论