我正在尝试在我的angular应用程序中使用来自https://www.regextester.com/94502的正则表达式。
所以我复制了正则表达式并将其放在两个/字符之间...
websiteRegex = /?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'^(?:http(s)\(\)\*\+,;=.]+$/;
website: ['', [Validators.maxLength(250), Validators.pattern(this.websiteRegex)]]
但这会导致编译错误:
Module parse failed: Invalid regular expression: /?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'^(?:http(s)\(\)\*\+,;=.]+$/: Nothing to repeat
我该如何解决这个问题呢?
发布于 2019-06-03 19:12:41
在使用正确的正则表达式时工作正常...
websiteRegex = /^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$/;
https://stackoverflow.com/questions/56426057
复制相似问题