Regex 正则表达式-查找不匹配的单词和点';不要以前缀开头
类似于,并且可能类似于 我需要找到所有不以“Regex 正则表达式-查找不匹配的单词和点';不要以前缀开头,regex,Regex,类似于,并且可能类似于 我需要找到所有不以“com.”开头的“somehost”实例 具体来说,我希望更改地址中“somehost”的实例,但不更改合同中的实例: <endpoint address="https://subsite.somehost.com/someservice.svc" ... contract="com.somehost.subsite.someservice.MyServiceSoap" /> <endpoint address="https
com.
”开头的“somehost
”实例
具体来说,我希望更改地址中“somehost”的实例,但不更改合同中的实例:
<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" />
它将匹配子网站.somehost
,其他子网站.somehost
,和.somehost
,如果我只想替换somehost
部分,这也毫无帮助。看起来这段时间(
)把事情搞砸了
(在我的情况下,我确实可以访问lookbehinds)您可以使用此负面lookbehind:
[\w-]+\.(?<!com\.)somehost(?:\.[\w-]+)+
[\w-]+\(?
i、 e.在模式中使用lookback(?就在somehost
之前)
[\w-]+\.(?<!com\.)somehost(?:\.[\w-]+)+