我遇到了將正則表達式從Python轉換爲Flex的問題。我的字符串是這樣的:Flex正則表達式轉換幫助
SELECT "col", othercol,\n "othercol3" FROM doesn'tmatter...
Python的比賽就好了:
>>> re.search('select(.*?)from', 'SELECT "col", othercol,\n "othercol3" FROM doesn\'tmatter...', re.DOTALL|re.IGNORECASE).groups()[0]
' "col", othercol,\n "othercol3" '
但是,當我嘗試在軟硬度:
var pattern:RegExp = /select(.*?)from/ig;
var match:Array = pattern.exec('SELECT "col", othercol,\n "othercol3" FROM doesn\'tmatter...');
trace(match);
match
最終總是空。我究竟做錯了什麼?我敢肯定,這顯然對經驗豐富的Flex程序員......
也許這個實現默認是非貪婪的,你必須忽略'?'? – thejh 2010-11-06 00:10:15