“?-mix:”在正则表达式中是什么意思,这在 javascript/jQuery 中是否有效?如果无效,什么是合适的替代品。
更新:这是完整的正则表达式/(?-mix:^[^,;]+$)/
它在 chrome 的 javascript 中使用,我收到以下错误:
未捕获的语法错误:无效的正则表达式:/(?-mix:^[^,;]+$)/: 无效的组
注意:我发现这很有帮助:How to translate ruby regex to javascript? - (?i-mx:..) and Rails 3.0.3
最佳答案
假设 perl 上下文,(?-mix)
这会
- -m 禁用多行匹配
- -i 禁用不区分大小写的匹配
- -x 禁用扩展的正则表达式空白
参见此处:http://www.regular-expressions.info/modifiers.html
Not all regex flavors support this. JavaScript and Python apply all mode modifiers to the entire regular expression. They don't support the (?-ismx) syntax, since turning off an option is pointless when mode modifiers apply to the whole regular expressions. All options are off by default.
关于javascript - 正则表达式中的 "?-mix:"是什么意思,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16238806/