我有一個正則表達式,用於替換短語,如果該短語不包含HTML錨標記或IMG標記。在這個例子中被搜索的短語是 「Hello World」 的如何將.Net正則表達式轉換爲php
的.NET正則表達式是
(?<!<a [^<]+)(?<!<img [^<]+)(?<=[ ,.;!]+)hello world(?=[ ,.;&!]+)(?!!.*</a>)
E.G.正則表達式應該在一個短語匹配 「世界你好」 之類
"one two three hello world four five"
但在一個短語像
"one two three <a href='index.html'> hello world </a> four five"
或
"one two three <img alt='hello world' \>four five"
它與相關的應該不匹配的Hello World以下是我最初開發.Net版本時的問題。 regular expression that doesn't match a string if it's the text within an html anchor tag
任何有關如何將其轉換爲PHP正則表達式的指導將非常感激。
這個正則表達式不能匹配任何.NET也。結束標記有一個斜槓(''),但表達式會查找反斜槓。 –
@DanielHilgarth感謝您的糾正,我已經更新了這個問題。 – Rich
現在有什麼問題? –