How to math multiline using C#?

S

shuiqing.li

Hi,

I met a question when I would match some lines using the pattern
"<td>(.*?)</td>" in flows :
===============
<td>Hi
hello world!
....
</td>
===============

The question is I'll match these lines between "<td>" and "</td>", but
can't math anything using this pattern.

Here is my code:
===============
using System.Text.RegularExpressions;
Regex r;
Match m;
r = new Regex("<td>(.*?)</td>",
RegexOptions.IgnoreCase|RegexOptions.Compiled|RegexOptions.Multiline);
for (m = r.Match(pageContent); m.Success; m = m.NextMatch()) {
if(m.Groups[1].ToString()!="")
System.Console.Out.WriteLine(m.Groups[1].ToString());
}
===============

Who can help me?

Thanks in advance,
Jason.Lee
 
S

shuiqing.li

I got it! Please replace the pattern as "(?<InnerText>[\s\S]*?)"
string result = m.Groups["InnerText"].Value;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top