简体   繁体   English

Java和ECMA-262(AS,JS)中正则表达式之间的差异

[英]Differences between regular expressions in Java and ECMA-262 (AS, JS)

I need to convert Java regular expressions into Actionscript regular expressions. 我需要将Java正则表达式转换为Actionscript正则表达式。

There apparently aren't any premade converters, so I'm trying to write one myself. 显然没有任何预制转换器,所以我试图自己写一个。 Is there any resource that'd list all the differences? 有没有列出所有差异的资源?

I'm aware of regular-expressions.info, but there doesn't seem to be a comprehensive listing of differences there. 我知道regular-expressions.info,但似乎并没有全面的差异列表。

Thanks 谢谢

I don't know of any existing converter, but if your target is specifically ActionScript and not just any ECMA-262 implementation, the job could be easier than you expected. 我不知道任何现有的转换器,但如果你的目标是专门的ActionScript而不是任何ECMA-262实现,那么这项工作可能比你预期的要容易。 AS3 is powered by PCRE , same as PHP's preg_ functions, so it supports lookbehind, atomic groups and possessive quantifiers, same as Java. AS3由PCRE驱动,与PHP的preg_函数相同,因此它支持lookbehind,原子组和占有量词,与Java相同。 It also supports Java's dotall and extended modes in addition to JS's ignore-case and multiline . 除了JS的ignore-casemultiline之外,它还支持Java的dotall扩展模式。 It supports the inline modifier syntax ( (?imsx) ) as well. 它也支持内联修饰符语法( (?imsx) )。

PCRE's Unicode support is better than Java's, but unfortunately, I don't think that's included in ActionScript. PCRE的Unicode支持比Java更好,但不幸的是,我不认为它包含在ActionScript中。 The Unicode functionality seems to be explicitly tied to the character encoding, which is UTF-8 in PCRE; Unicode功能似乎与字符编码明确相关,即PCRE中的UTF-8; I believe ActionScript uses UTF-16 in accordance with ECMA-262. 我相信ActionScript根据ECMA-262使用UTF-16。 Anyway, its Unicode support seems to be minimal, same as JavaScript's. 无论如何,它的Unicode支持似乎很小,与JavaScript相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM