Table Stripping Regex
Posted: Wed May 13, 2009 6:02 pm
I think I've seen software advertised that will strip table tags. In other words, every tag that looks like any of the following:
<tr bgcolor="FFFFFF">, <TR valign=Top>, <tr width: 75% FONT=Arial, Verdana, valign=top>
...will be reduced to a simple <tr>. Of course, you can do the same thing with a table cell tag - <td> (I think).
I have three questions...
1. What's the basic regex used in this operation? I assume there's a relatively simple regex script that can be used to strip any kind of tag, simply replace <table> with <tr> or <td>.
2. Is there a way to strip ALL table tags - <table>, <tr> and <td> in one operation?
3. Once my table tags have all been stripped, is there a regex script that will let me add an attribute to every other table row?
For example, suppose my table looks like this:
How would I convert it to this?:
Thanks.
P.S. Is your search function working properly? I typed in strip table tags, and it ignored "table." A similar search for stripping <tr> tags ignored <tr>.
<tr bgcolor="FFFFFF">, <TR valign=Top>, <tr width: 75% FONT=Arial, Verdana, valign=top>
...will be reduced to a simple <tr>. Of course, you can do the same thing with a table cell tag - <td> (I think).
I have three questions...
1. What's the basic regex used in this operation? I assume there's a relatively simple regex script that can be used to strip any kind of tag, simply replace <table> with <tr> or <td>.
2. Is there a way to strip ALL table tags - <table>, <tr> and <td> in one operation?
3. Once my table tags have all been stripped, is there a regex script that will let me add an attribute to every other table row?
For example, suppose my table looks like this:
Code: Select all
<table>
<tr>
<td>(Some text)</td>
</tr>
<tr>
<td>(More text)</td>
</tr>
</table>
Code: Select all
<table>
<tr>
<td>(Some text)</td>
</tr>
[color=#FF0000]<tr class="even">[/color]
<td>(More text)</td>
</tr>
</table>
P.S. Is your search function working properly? I typed in strip table tags, and it ignored "table." A similar search for stripping <tr> tags ignored <tr>.