[英]How to convert a .Net regular expression to php
我有一個正則表達式,如果該短語不包含在HTML錨標記或IMG標簽中,則該表達式用於替換該短語。 在此示例中,要搜索的短語是“ hello world”
.net正則表達式為
(?<!<a [^<]+)(?<!<img [^<]+)(?<=[ ,.;!]+)hello world(?=[ ,.;&!]+)(?!!.*</a>)
EG正則表達式應匹配“ hello world”,例如
"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"
從我最初開發.Net版本起,它與以下問題相關聯。 如果它是html錨標記中的文本,則不匹配字符串的正則表達式
任何有關如何將其轉換為php regex的指導將不勝感激。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.