0

如果我的文本包含“\ / > <”等字符并且我想找到它们,那么正则表达式模式应该是什么。这是因为正则表达式将“/”视为搜索模式的一部分,而不是单个字符。

例如,我想Super Kings从字符串中查找<span>Super Kings</span>,使用 VB 2010。

谢谢!

4

2 回答 2

1

试试这个:

\bYour_Keyword_to_find\b

\b在 RegEx 中用于匹配单词边界。

[编辑]

你可能正在寻找这个:

(?<=<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 “&lt;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 “&lt;>” «[^<>]+?»
      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 “&lt;/span>” literally «</span>»
-->

[/编辑]

于 2012-05-07T04:10:53.897 回答
1

在正则表达式中,您必须转义/with \

例如,尝试:或<span>(.*)<\/span> <span>([^<]*)<\/span><span>(.*?)<\/span>

阅读更多内容: http ://www.regular-expressions.info/characters.html

于 2012-05-07T04:19:24.087 回答