Hong Wang
Hong Wang

Reputation: 73

C# regex to match a number in fourth line

I'm new to C# regex. I haven't been able to match the number in the fourth line (including a blank line on third line) using C# regex:

 <th>Total Members</th>
 <td>

    87
 </td>

Upvotes: 0

Views: 131

Answers (3)

Sabuj Hassan
Sabuj Hassan

Reputation: 39365

Match match = Regex.Match(input, @"<th>Total Members</th>\s*<td>\s*(\d+)\s*</td>", RegexOptions.Multiline);
if (match.Success)
{
    Console.WriteLine(match.Groups[1].Value);
}

Upvotes: 1

Mobility
Mobility

Reputation: 263

Try using this regular expression

^[0-9]{2}$

Upvotes: 0

aloisdg
aloisdg

Reputation: 23521

It seems that your are going to parse html with regex.

I think you should use HTML Agility Pack instead.

Upvotes: 0

Related Questions