我正在使用regex表达式来验证输入。我想匹配确切的字符串"spe1“和"spe1.grl”。
到目前为止,我已经编写了以下代码:
'\\b(?!i' + this.stringToIgnore + '\\b)\\w+';其中this.stringToIgnore = 'spe1‘
如果我输入:
"spe1“(注意空格) “spe1”
我想在输入以下内容后立即匹配:
"spe1“(无需在末尾添加空格或点) "spe1.grl“(无需在末尾添加空格或点)
谢谢你的帮助
发布于 2019-05-01 08:58:01
在使用了一个在线Regex工具之后,我找到了我自己问题的答案。如果有人需要的话,我会发出去:
'\\b(?!' + this.stringToIgnore + '\\b)\\w+';或
''\\b(?!' + this.stringToIgnore + '|' + this.stringToIgnore.toUpperCase + '\\b)\\w+';如果用户打开大写键的话。
https://stackoverflow.com/questions/55925363
复制相似问题