テキストに "\ /> <"などの文字が含まれている場合はどうすればよいですか?これは正規表現がそれが検索パターンの一部であるように "/"を扱い、個々の文字ではないためです。例えば"/"、 "<" and ">"のような文字の正規表現検索
、私はVBに2010年
おかげを使用して、文字列<span>Super Kings</span>
からSuper Kings
を見つけたいです!
テキストに "\ /> <"などの文字が含まれている場合はどうすればよいですか?これは正規表現がそれが検索パターンの一部であるように "/"を扱い、個々の文字ではないためです。例えば"/"、 "<" and ">"のような文字の正規表現検索
、私はVBに2010年
おかげを使用して、文字列<span>Super Kings</span>
からSuper Kings
を見つけたいです!
ただ、この方法を試してください。
\bYour_Keyword_to_find\b
\b
は、単語の境界を一致させるための正規表現で使用されています。
[EDIT]
あなたはこのを探している可能性があります:
(?<=<span>)([^<>]+?)(?=</span>)
説明:
<!--
(?<=<span>)([^<>]+?)(?=</span>)
Options: case insensitive;^and $ match at line breaks
Assert that the regex below can be matched, with the match ending at this position (positive lookbehind) «(?<=<span>)»
Match the characters “<span>” literally «<span>»
Match the regular expression below and capture its match into backreference number 1 «([^<>]+?)»
Match a single character NOT present in the list “<>” «[^<>]+?»
Between one and unlimited times, as few times as possible, expanding as needed (lazy) «+?»
Assert that the regex below can be matched, starting at this position (positive lookahead) «(?=</span>)»
Match the characters “</span>” literally «</span>»
-->
[/ EDIT]
正規表現であなたがエスケープする必要があります/
と\
。例えば
、試してみてください。
<span>(.*)<\/span>
<span>([^<]*)<\/span>
または<span>(.*?)<\/span>
から続きを読む:あなたがXMLまたはHTMLを解析する正規表現を使用しようとするべきではありません http://www.regular-expressions.info/characters.html
。あなたのためにそれを行うhtmlまたはxmlパーサーを見つけるか、またはあなたが溺れるでしょう。 –
VB 2010 Win32とWindows Phone 7アプリケーションの両方で動作するHTMLパーサのアドバイスをお願いしますか? – antikbd
あなたは多くの同情を得ることはありません。正規表現マッチャーのドキュメントを読むと、本当にひどい正規表現エンジンを持っていない限り、検索パターンの一部として通常使用される文字のマッチング方法がわかります。 –