Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > RegEx: replace HTML block with specific text inside

Thread Tools

RegEx: replace HTML block with specific text inside

Claudio Biagioli
Posts: n/a
I have to replace a full HTML block (in this case a <TR>) which must contain
specific word(s).
<td>.... HELLO ....</td>

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

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

Any Idea?


Reply With Quote
Posts: n/a
Well there is nothing like the feeling of creating your own regular expressions, so I would highly encourage it. 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

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace Text at Specific Positions Across Files Shiny Hydra Ruby 11 03-19-2010 05:33 PM
Fo:Block can you check to see if a block contains any text by using the block id? morrell XML 1 10-10-2006 07:18 PM
Replace text inside html tags? Perl Misc 4 01-31-2005 09:32 AM
How do you make sure a frameset is loaded? I'm trying to open a frameset in a new window which shows a specific html page in a specific frame ck388 Javascript 1 09-24-2003 08:32 PM