【问题标题】:What is the right regular expression for this web link?此 Web 链接的正确正则表达式是什么?
【发布时间】:2016-01-26 09:32:53
【问题描述】:

我想找到一些网络链接的正则表达式。像这样: example.com/bbsdoc.php?board/Picture 或者 example.com/bbsdoc.php?board=Picture 我在这里测试它:https://regex101.com/

我发现 board\/Picture 与第一个链接中的 board/Picture 匹配。 board=Picture 与第二个链接中的匹配。

但是如何制作一个像下面这样的正则表达式来匹配整个链接呢? example.com*board\/图片 在测试网站显示这个错误:https://regex101.com/

【问题讨论】:

标签: regex


【解决方案1】:

很难从 2 个链接中说出来,但是像 example\.com.*?\W+board[\/=]Picture 这样的东西会起作用

【讨论】:

  • 在惰性点匹配模式.*?之后使用\W+的目的是什么?
  • 检查 &&/ - 正如我所写 - 很难从 2 个链接中分辨出什么格式
  • 我相信你可以用\b替换\W+
  • 真的,给猫剥皮的方法总是不止一种 :)
  • 是的,但有些成本更低。
猜你喜欢
  • 2013-04-07
  • 2011-06-15
  • 2015-06-09
相关资源
最近更新 更多