开发者

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)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜