<p>我在匹配和替换某些不包含在http://</p>
<p>当前Regex:</p>
<pre><code> http://.*?\s+
</code></pre>
<p>这与模式匹配<code>http://www.egg1.com <a href="http://www.egg2.com" rel="nofollow">http://www.egg2.com</a></code></p>
<p>我需要一个regex来匹配http://</p>
<p>示例:</p>
<pre><code>"This is a sample. http://www.egg1.com and http://egg2.com. This regex will only match
this egg1 and egg2 and not the others contained inside http:// "
Match: egg1 egg2
Replaced: replaced1 replaced2
</code></pre>
<p>最终输出:</p>
<pre><code> "This is a sample. http://www.egg1.com and http://egg2.com. This regex will only
match this replaced1 and replaced2 and not the others contained inside http:// "
</code></pre>
<p>问题:
需要匹配某些模式(例如:egg1 egg2),除非它们是http:///的一部分。如果egg1和egg2存在于http:///中,则不要匹配它们</p>