我尝试匹配“Test”
var regex = new RegExp('^((?!Test).)*$')
regex.test('Test')
但是,这不起作用。
我需要一个仅当指定字符串存在时才返回 true 的正则表达式。
最佳答案
这只是^Test$
,但你也可以这样做string === 'Test'
关于javascript - 仅当指定字符串存在时,正则表达式才返回 true,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22366223/