Tyi*_*ilo 3 regex string regex-negation
我想制作一个匹配所有相关补丁的正则表达式模式.
我想要匹配的内容:
img src="image.png" img src="http_image.png"
我不想匹配的内容:
img src="http://example/image.png"
我尝试与这些模式匹配,但它们都不起作用:
\src="[^http://]\ \src="^(http://)\ \src="[^h][^t][^t][^p][^:][^/][^/]\ \src="([^h][^t][^t][^p][^:][^/][^/])\
我把<>的img标签留下了,因为我不能把它写成代码.
src属性将始终使用双引号(")而非单引号(')格式化.
它将始终包含"http"源,而不是"https"或其他.
解决这个问题的方法是使用负前瞻断言:
^img src="(?!http:\/\/\S+).*"$
Run Code Online (Sandbox Code Playgroud)
^ : Start anchor
img src=" : Literal img src="
(?!http:\/\/\S+) : To ensure the string following " is not a URL
.* : Anything else is allowed
" : Literal "
$ : End anchor
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
324 次 |
| 最近记录: |