クリムゾンの答えは、テストとして使用してRegex Powertoyでテストする際に機能しません<Escaped characters \<\> are right in the middle of this sentence.>, <Here is another sentence.>
が、これは機能するようです:
/<(?<!\\<).*?>(?<!\\>)/gi
私に2つの一致を与えます:
<Escaped characters \<\> are right in the middle of this sentence.>
そして<Here is another sentence.>
編集:ガンボが一致しなかったと言った文字列を調べました。regex.powertoy.org で一致させるのに問題はありません。
代替テキスト http://img362.imageshack.us/img362/3227/regexpowertoyorg.png
テストでは、元の投稿された正規表現を次のように変更しました。/(?<!\\)<(.*?)(?<!\\)>/gi
これはより効率的です(プローブが少ない)。
また、regex.powertoy.org の出力で、4 番目の文字列 ( \<hello <match\<this\>> but not this\> looks odd... the printed replacement is just
match but the match detail clearly shows that the match is correct;
match\ . But I also notices that the first and third test string replacements don't print the "
`" が山かっこをエスケープしていることに気付きました。少し (完全ではありませんが) 遊んだ後、これはテキストの表示に問題があると思います。 javascript を使用すると、エスケープされた山かっこはエスケープ文字を出力せず、空でない山かっこはまったく出力されません.これは、javascript がそれを HTML として認識しているためだと思います.そう;この正規表現は機能していると思います.ただし、オフラインでテストする必要があります。