在VS 2012中使用正则表达式

时间:2015-06-03 13:41:20

标签: regex visual-studio-2012

我试图在VS 2012中使用Regular expression找到与该格式匹配的字符串:

<data anything here>
</data>

2 个答案:

答案 0 :(得分:2)

这应该可以解决问题:

^<data ([^>]+)>\r\n</data>

答案 1 :(得分:2)

<强>正则表达式

\<data ([^\>]+)\>\r\n\<\/data\>

正则表达式描述:

\< matches the character < literally
data  matches the characters data  literally (case insensitive)
1st Capturing group ([^\>]+)
    [^\>]+ match a single character not present in the list below
    Quantifier: + Between one and unlimited times, as many times as possible, giving back as needed [greedy]
    \> matches the character > literally
\> matches the character > literally
\r matches a carriage return (ASCII 13)
\n matches a line-feed (newline) character (ASCII 10)
\< matches the character < literally
\/ matches the character / literally
data matches the characters data literally (case insensitive)
\> matches the character > literally

注意: 这会将anything here文本捕获到捕获组1中,您可以在Visual Studio中使用{{1}替换}符号。