View Full Version : Automatic <table> replacement into <div> tags
nikos101
11-08-2007, 11:00 AM
I can remove all table tags in a text editor by
</?table[^>]*>|</?tr[^>]*>|</?td[^>]*>|</?thead[^>]*>|</?tbody[^>]*>
But how can I replace all <td> and <table> tags with the corresponding <div> and </div> tags?
I can replace all into <div> but then I have to change the end tags into </div>
Probably I have to do it in 2 steps, one for <div> and one regex for </div>
btw why is it important to have
*>
from
</?table[^>]*>
to find the </table> tags?
nikos101
11-08-2007, 12:21 PM
OK I've solved it.
the first regex is
</table[^>]*>|</tr[^>]*>|</td[^>]*>|</thead[^>]*>|</tbody[^>]*>
which changes matches to </div>
and the second is
<table[^>]*>|<tr[^>]*>|<td[^>]*>|<thead[^>]*>|<tbody[^>]*>
which changes matches to <div>
felgall
11-08-2007, 08:23 PM
Why do you want to replace a table with divs. Divs used inappropriately are just as bad as tables used inappropriately. You should be using the correct tags for what your content actually is.
oracleguy
11-08-2007, 10:02 PM
Why do you want to replace a table with divs. Divs used inappropriately are just as bad as tables used inappropriately. You should be using the correct tags for what your content actually is.
Exactly, if you have tabular data, representing it using divs is just has bad (if not worse) as using tables for layout.
nikos101
11-09-2007, 09:12 AM
yeah , I've just found out by doing by div replacements. Its a mess
felgall
11-09-2007, 09:05 PM
The correct way to create your HTML is to surround all your content with the HTML tags that identify what that content actually is. For example most forms of navigation bars should be marked up as a list.
Use tables for tabular data. Use divs with ids for divisions of your page such as header, footer etc. Use divs with classes to represent any block level tags that you need where there isn't an HTML tag that is appropriate.
In most cases you should then be able to style your content to get the appearance you want without the need to add any additional semantically meaningless div tags.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.