我有一些有用的经常EX pressions 的在Perl。有没有一种简单的方法将其转化为常规的前pressions .NET的方言?
I have some useful regular expressions in Perl. Is there a simple way to translate them to .NET's dialect of regular expressions?
如果不是,是否有差异简明参考?
If not, is there a concise reference of differences?
有一个在http://www.regular-ex$p$pssions.info/refflavors.html.
大多数的基本要素是相同的,所述的区别是:
Most of the basic elements are the same, the differences are:
的细微差异:
在统一code转义序列。在.NET中是 u200A
,在Perl是 x {200A}
。
NET中v
只是一个垂直选项卡(U + 000B),在Perl它代表了垂直空白级。当然也有这样符 v
在Perl,因为。
在有条件EX pression在.NET命名引用((名)吗|)?
,而(( <名称>)是|否)
在Perl。
Unicode escape sequences. In .NET it is u200A
, in Perl it is x{200A}
.
v
in .NET is just the vertical tab (U+000B), in Perl it stands for the "vertical whitespace" class. Of course there is V
in Perl because of this.
The conditional expression for named reference in .NET is (?(name)yes|no)
, but (?(<name>)yes|no)
in Perl.
有些元素是Perl的只有:
占有欲量词( X'+
, X * +
, X ++
等)。使用非回溯SUBEX pression((&GT; ...)
)。而不是
命名UNI code转义序列 N {拉丁小写字母x}
, N {U + 200A}
。
案例折叠和逃逸
→
(小写的下一个字符), U
(大写下一个字符)。
→
(小写), U
(大写), Q
(引号元字符),直到。 E
。
Possessive quantifiers (x?+
, x*+
, x++
etc). Use non-backtracking subexpression ((?>…)
) instead.
Named unicode escape sequence N{LATIN SMALL LETTER X}
, N{U+200A}
.
Case folding and escaping
l
(lower case next char), u
(upper case next char).
L
(lower case), U
(upper case), Q
(quote meta characters) until E
.
code (?{...})
在递归(R)
,(R1)
,(R&安培;名)
定义(DEFINE)
。
code (?{…})
recursive (R)
, (R1)
, (R&name)
define (DEFINE)
.
(?P&LT;名称&gt; ...)
。使用(LT;名称&gt; ...)。
而不是
(P =名)
。使用 K&LT;名称&gt;
而不是
(?P&GT;名称)
。没有等效的.NET。
(?P<name>…)
. Use (?<name>…)
instead.
(?P=name)
. Use k<name>
instead.
(?P>name)
. No equivalent in .NET.
有些元素是.NET只有:
在可变长度查找落后。在Perl中,积极查找落后,使用 氏/ code>代替。
在任意定期EX pression有条件EX pression ((图案)吗|)。
字符类减法(无证?) [az- [DW]]
均衡组(小于?-name&GT; ...)
。这可能与code评价的断言模拟
后跟一个({...}?)(安培;名)
。
Variable length look-behind. In Perl, for positive look-behind, use K
instead.
Arbitrary regular expression in conditional expression (?(pattern)yes|no)
.
Character class subtraction (undocumented?) [a-z-[d-w]]
Balancing Group (?<-name>…)
. This could be simulated with code evaluation assertion (?{…})
followed by a (?&name)
.
参考文献:
的的.NET Framework 4:普通防爆pression语言元素的
的 perlre 的