Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我们有几篇博客文章包含链接(太多无法更改),这些链接指向我们主网站上的旧 URL 结构。URL 中包含几个连字符作为默认分隔符。
考虑:
example.com/My-Awesome-Product
我需要将包含多个连字符的所有网址(例如上面的示例)写入:
example.com/Product/My-Awesome-Product
如果传入的 url 是:
example.com/Other-Page
...那么它不应该匹配。
有任何想法吗?提前致谢。
^(?![^-]*-[^-]*$)^(.*\/)
试试这个。替换为
$1Product/
见演示。
http://regex101.com/r/hQ1rP0/4