我有一个正则表达式模式作为(http(s)?://)?([\w-]+\.)+[\w-]+(/[\w- ;,./?%&=]*)?,如果我使用一些在线工具来检查它,它工作得很好,但是当我在ng-pattern中使用它作为ng-pattern="(http(s)?://)?([\w-]+\.)+[\w-]+(/[\w- ;,./?%&=]*)?"时,它抛出了错误吗?
Invalid regular expression: /^(http(s)?://)?([w-]+.)+[w-]+(/[w- ;,./?%&=]*)?$/: Range out of order in character class我搜索了许多关于这个问题的问题,但似乎没有一个是有效的
发布于 2017-06-19 15:16:18
将其更改为
(http(s)?:\/\/)?([\w-]+\.)+[\w-]+(\/[\w- ;,.\/?%&=]*)?发布于 2017-06-19 15:17:48
你必须分配:
$scope.regex = "(http(s)?://)?([\w-]+\.)+[\w-]+(/[\w- ;,./?%&=]*)?";然后写下:
ng-pattern="{{regex}}"https://stackoverflow.com/questions/44624344
复制相似问题