簡體   English   中英

Flex正則表達式轉換幫助

[英]Flex Regular Expression Conversion Help

我在將正則表達式從Python轉換為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" '

但是當我在Flex中嘗試時:

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

match始終以null結尾。 我究竟做錯了什么? 我相信對於經驗豐富的Flex程序員來說這是顯而易見的...

嘗試使用眾多Flex正則表達式測試器之一:

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

一方面,您正在使用dotall等,所以您可能想知道Flex為此使用了“ s”標志。 並且“ x”標志會忽略空格等。例如,

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

在您的榜樣上對我有用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM