[英]Conditional regex on quotes and double quotes
我有这个正则表达式:
/templateUrl:\s*'([^']+?\.html)'/g
我也试图接受双引号。 到目前为止,我了解到这是创造条件的方式:
(?(?=regex)then|else)
所以我会得到:
/templateUrl:\s*(?(?=')([^']+?\.html')|(?(?=")([^"]+?\.html")))/g
但这不起作用..我还缺少什么?
编辑:
巨型OR呢?
/templateUrl:\s*('([^']+?\.html)')|("([^"]+?\.html)")/g
您也有这种运作良好的可能性
(templateUrl:)(?:\\s*)(["|'](.*\\.html)["|'])
编辑以吸收反引号
templateUrl:\\s*([<="|'|`].*\\.html[="|'|`])
您将捕获没有多余空间的templateUrl
不带引号test.html
的html路径和带引号"test.html"
或'test.html'
或`test.html`的路径。
希望对您有所帮助:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.