Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with regular expressions 1

Status
Not open for further replies.

noyes99

Programmer
Jun 25, 2002
38
IN
I am looking for some help with a regular expression. I have a scenarios, where I have strings, with <table> within <table> tags within them. I need to replace the outermost table tags with <pre><table>. How do I write this reg ex. What I am thinking of doing is this.

Take a string. Replace the inner tables with a @@@TABLEOPEN@@@ and @@@TABLECLOSE@@@ then replace all the table tags with <pre><table> and then replace the placeholder with <table>

ie. I would want
EGYEYUGEYUEUYEY<table cellpadding="23"><tr><td><table cellspacing="23"><tr><td>HGDHDHDJK</td></tr></table></td></tr></table>EGYEYUGEYUEUYEYEGYEYUGEYUEUYEY

with

EGYEYUGEYUEUYEY<pre><table cellpadding="23"><tr><td><table cellspacing="23"><tr><td>HGDHDHDJK</td></tr></table></td></tr></table></pre>EGYEYUGEYUEUYEYEGYEYUGEYUEUYEY

Any help would be appreciated
 
Try it with:
regsub {<table.+<table.+/table>.+/table>} $yourstring {<pre>&</pre>} yourstring

with "$yourstring" standing for one complete line as described above
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top