admin管理员组文章数量:1301528
What does "?-mix:" mean in regex, also is this valid in javascript/jQuery? If it's not valid, what is an appropriate substitute.
Update: This is the full regex /(?-mix:^[^,;]+$)/
Its used in javascript in chrome, and I'm getting the following error:
Uncaught SyntaxError: Invalid regular expression: /(?-mix:^[^,;]+$)/: Invalid group
Note: I found this helpful: How to translate ruby regex to javascript? - (?i-mx:..) and Rails 3.0.3
What does "?-mix:" mean in regex, also is this valid in javascript/jQuery? If it's not valid, what is an appropriate substitute.
Update: This is the full regex /(?-mix:^[^,;]+$)/
Its used in javascript in chrome, and I'm getting the following error:
Uncaught SyntaxError: Invalid regular expression: /(?-mix:^[^,;]+$)/: Invalid group
Note: I found this helpful: How to translate ruby regex to javascript? - (?i-mx:..) and Rails 3.0.3
Share edited May 23, 2017 at 12:32 CommunityBot 11 silver badge asked Apr 26, 2013 at 14:22 user160917user160917 9,3504 gold badges54 silver badges63 bronze badges 02 Answers
Reset to default 10Assuming perl context, (?-mix)
this would
- -m disable multiline matching
- -i disable case insensitive matching
- -x disable extended regex whitespace
See here: 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.
Since you've now made it clear that the context here is javascript, I don't think javascript supports that flag syntax so it's plaining about ^
being found in the middle of a regex. Since you can never find the start of a match in the middle of a match, this makes an invalid regex.
In javascript, you specify flags outside the regex itself such as:
var re = /^[^,;]+$/mi;
or as an argument like this:
var re = new RegExp("^[^,;]+$", "mi");
The x
flag is not supported in javascript and this particular regex does not need the i
flag.
What this particular regex is trying to do is to tell you whether the string you are matching it against contains all characters other than ,
and ;
and is not empty.
本文标签: javascriptWhat does quotmixquot mean in regexStack Overflow
版权声明:本文标题:javascript - What does "?-mix:" mean in regex - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741675769a2391873.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论