我正在尝试执行替换。请看下面的字符串:更换RegEx时搜索周围的空格
Please replace something in this sentence.
and replace <b>something </b> in this sentence.
But not here http://www.mysite.com/something/mypage.html
Or here \\myserver\something\myshare\
我想somethingelse
更换something
,但是something
可以出现在我的源代码的URL或UNC,我不希望替换。我也有一些有趣的HTML继续。
这是我使用的模式:其中一期工程
\b[^/\\]Something[^/\\]\b
,但是我得到的第一something
背部以及周围的空间。如果我有somethingelse
取代something
我得到的结果是:
Please replacesomethingelsein this sentence.
and replace <b>somethingelse </b> in this sentence.
But not here http://www.mysite.com/something/mypage.html
Or here \\myserver\something\myshare\
二审工作,先用空间没有。
如何忽略something
附近是否存在空格?谢谢。
难道你不能让他们捕获组,并在替换中使用它们吗? – Loamhoof 2013-04-24 14:01:11
我试过'\ b [^/\\](Something)[^/\\] \ b',但不知道如何替换SubMatch。那是你在想什么? – SLeepdepD 2013-04-24 14:04:55
查看我的答案:) – Loamhoof 2013-04-24 14:18:13