【发布时间】:2016-01-14 00:21:44
【问题描述】:
类似于Regex - Find all matching words that that don't begin with a specific prefix,也可能类似于Regex for matching whole words that contain dots
我需要找到所有不以“com.”开头的“somehost”实例
具体来说,我希望更改 address 中的“somehost”实例,而不是 contract:
<endpoint address="https://subsite.somehost.com/someservice.svc" ...
contract="com.somehost.subsite.someservice.MyServiceSoap" />
<endpoint address="https://othersub.somehost.com/anotherservice.svc" ...
contract="com.somehost.othersub.anotherservice.MyOtherServiceSoap" />
改编first linked question中的“(不是女朋友)朋友”的例子,我试过了:
\b(?!com\.)[\w\.]*somehost\b
将匹配subsite.somehost、othersub.somehost 和.somehost,如果我只想替换somehost 部分,这也没有任何帮助。看起来那个时期(.)把事情搞砸了......
(在我的情况下,我确实可以访问lookbehinds)
【问题讨论】:
标签: regex