【发布时间】:2018-10-21 18:09:06
【问题描述】:
/^(?! )(?=.*[a-z])(?=.*[A-Z])(?=.*\d)([a-zA-Z\d!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ ]{8,})(?<! )$/
在 regex101.com、chrome 控制台甚至 joi npm runkit 中完美运行。但是当在代码中使用时,Joi 会给出错误 -
SyntaxError: Invalid regular expression: {above regex}: Invalid Group
你能帮我解决这个问题吗?
【问题讨论】:
-
(?<! )是一个lookbehind,目前它只适用于Chrome(支持ECMAScript 2018)。 -
我在 joi npm runkit 中尝试过。它工作得很好,但是在代码中使用时它给了我错误
-
使用this fix。
-
通过更新我的 npm 库解决了这个问题
-
thanx @WiktorStribiżew 你的解决方案有帮助