开发者

Flex Regular Expression Conversion Help

I'm having a problem converting a regular expression from Python into Flex. My string is something like this:

SELECT "col", othercol,\n "othercol3" FROM doesn'tmatter...

Python matches just fine:

>>> re.search('select(.*?)from', 'SELECT "col", othercol,\n "othercol3" FROM doesn\'tmatter...', re.DOTALL|re.IGNORECASE).groups()[0]

' "col", othercol,\n "otherco开发者_StackOverflow中文版l3" '

But when I try it in Flex:

var pattern:RegExp = /select(.*?)from/ig;
var match:Array = pattern.exec('SELECT "col", othercol,\n "othercol3" FROM doesn\'tmatter...');
trace(match);

match always ends up null. What am I doing wrong? I'm sure it's obvious to a seasoned Flex programmer...


Try one of the many Flex regular expression testers out there:

http://www.idsklijnsma.nl/regexps/

For one thing, you're using dotall, etc., so you might want to know that Flex use the "s" flag for that. And the "x" flag ignores whitespace, etc. For example,

pattern:RegExp = /select.+?from/gis;

works for me on your example.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜