ruby - 哪些语言支持扩展正则的?
大家讲道理
大家讲道理 2017-04-21 11:19:17
0
5
677

就是多行带注释的。

我知道的有Ruby——需要加x选项

/\d{4}-? # 年
\d{1,2}-? # 月
\d{1, 2} # 日
/x

LiveScript——用//代替/

//
\d{4}-? # 年
\d{1,2}-? # 月
\d{1, 2} # 日
//

还有哪些?

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(5)
大家讲道理

This is PCRE_EXTRA Modifier: PASSING MODIFIERS TO THE REGULAR EXPRESSION ENGINE
Usually add X Modifier/Option/Compilation Flag
Implementations of the PCRE series should all support this function. So you just need to see if the language has a PCRE library, or if its Regex implementation supports X Option.

Popular language, such as,
PHP has: http://php.net/manual/en/reference.pcre.pattern.modifiers.php
Python also supports: http://docs.python.org/2/library/re.html#re.VERBOSE
JavaScript does not work by default because it is not PCRE and requires the XRegExp extension: http://www.xregexp.com/
Both Java and C# are available:
- Java Pattern.COMMENTS
- C# X RegExp Option

Java and C# are available, as are JVMs such as Groovy or the .Net series.

By the way, strictly speaking, this is not something at the language syntax level. It’s just that Ruby or JS supports RegExp literals, so in this sense there is no distinction between languages. It’s just a comparison of how to write multi-line strings in C/C++. unnatural.

伊谢尔伦

All scripting languages ​​are supported, just extend pcre

PHPzhong

CoffeeScipt also supports it.

///
\d{4}-? # 年
\d{1,2}-? # 月
\d{1, 2} # 日
///
洪涛

nark regular engine supports intersection and difference operations, and also supports multiple regular expressions: you can know which of a bunch (possibly millions) of regular expressions match in one scan.

PHPzhong

c and c++ are not supported

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template