简体   繁体   English

字符类Regex Firefox中的范围无效

[英]Invalid range in character class Regex Firefox

I got Invalid range in character class issue when trying to use regex 尝试使用正则表达式时,字符类问题出现无效范围

/^[a-zA-Zа-яА-ЯЁё0-9_-\s]{6,20}$/

But the issue is only in Firefox, in Chrome it's ok. 但问题仅在Firefox中,在Chrome中也可以。

With this regex I am trying to say "only latin, russian letters, numbers, space and '_' and '-' signs allowed" 使用此正则表达式,我想说的是“仅允许使用拉丁文,俄语字母,数字,空格以及'_'和'-'符号”

The _-\\s is creating a range between the underscore and space characters. _-\\s在下划线和空格字符之间创建一个范围。 You need to either escape the - as in _\\-\\s or put it at the end: 您需要转义-_\\-\\s或放在末尾:

[a-zA-Zа-яА-ЯЁё0-9_\s-]

Also beware of the а-я range. 还要注意а-я范围。 If this is the same as the Latin 1 a the range may not be what you expect at all. 如果与拉丁1 a相同,则范围可能根本不是您期望的范围。

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

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