RegEx: replace HTML block with specific text inside

  • Thread starter Claudio Biagioli
  • Start date
C

Claudio Biagioli

I have to replace a full HTML block (in this case a <TR>) which must contain
specific word(s).
Example
<tr>
<td>.... HELLO ....</td>
</tr>

must be substituted by another fixed string, but all other <tr> shouldn't
change.

I'm using RegEx.Replace but cannot find the correct Regular
Expression.

Any Idea?

Thanks!
 
G

Guest

Well there is nothing like the feeling of creating your own regular expressions, so I would highly encourage it. http://www.regxlib.com/ is a pretty good site for learning how to create them

A while back I had a similiar problem where I needed to strip off "standard" HTML tags that every web page should have, so below is a sample of what I used to strip off the Title tag and everything inbetween. I would imagine that you can replace the (.*) with whatever you need and get it to work for you

(/<title>(.*)<\/title>\r\n/ig, "")

One catch though is that I created this for use in ASP and I've never used regular expressions in .NET (yet), so if you get this to work please let me know

Thanks
Jeremy
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top