javascript - 正则表达式中的 "?-mix:"是什么意思

标签 javascript jquery regex

“?-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/

相关文章:

jquery - Twitter bootstrap 让 Accordion 的第一个面板默认打开

c# - Asp.Net core 3.0 中的 URL 重写

javascript - Angularjs ui utils 突出显示过滤器破坏了搜索应用程序

ruby - 使捕获正则表达式重复

Javascript 正则表达式 - 替换非数字字符

javascript - 分页器表在 Jquery ajax 查询后不分页

javascript - 取消选中所有复选框后如何清除输入

javascript - 使用 Gulp 根据目录名称连接和重命名文件

javascript - 在 setTimeout() 中使用 $(this);

javascript - 根据输入类型确定值