我有这个正则表达式:
[az]+[:.].*?\s
我在以下文本上运行它:
regexbuddy.com
www.regexbuddy.com
http://regexbuddy.com cvc
http://www.regexbuddy.com cvcv
http://www.regexbuddy.com/ g
http://www.regexbuddy.com/index.html f
http://www.regexbuddy.com/index.html?source=library f
You can download RegexBu ddy at http://www.regexbuddy.com/download.html. f
"www.domain.com/quoted URL with spaces"
http://10.2.2.1.2/ttxx/txt/gg v
support@regexbuddy.com
Run Code Online (Sandbox Code Playgroud)
我需要匹配以下内容 - 仅粗体文本:
http://10.2.2.1.2/ttxx/txt/gg v support@regexbuddy.com我怎样才能做到这一点?
更新
@slhck 您修改后的正则表达式几乎匹配所有内容,除非 url 以 www 开头。例如 - “www.domain.com/quoted URL with space”
我对正则表达式进行了一些更改以匹配领先的 www。看起来像
(https?)://。(?=\s)|(www.)。?(?=\s)
你能回顾一下吗?并建议是否存在更好的匹配方法。
regex ×1