Extract Content From Div Tag C# Regex
I need to extract this content inside the divtestimonial1 div I am using the following regEx, but its only returning the first line Regex r = new Regex('<div([^<]*<(?!
Solution 1:
Regular expressions are generally not a good choice for parsing HTML. You might be better off using a tool such as HTML Agility Pack, so I would suggest you use that.
That being said, you can match your particular sample input using this Regex:
<div.*?id="divtestimonial1".*?>.*</div>
But it might break in your real-world scenario. One of the troubles with Regex and HTML is properly detecting nesting of tags, etc.
Post a Comment for "Extract Content From Div Tag C# Regex"