Advertisement

10.24.2004 at 07:17PM PDT, ID: 21180806
[x]
Attachment Details

Regex help

Asked by Gitcho in Miscellaneous Web Development

Hi ... I'm trying to take a chunk of badly formatted/indented code, and reformat it with the proper indentation.

I need a regular expression that will put all tags in an array, so I can recontruct the HTML like the example below.

I thought regular expressions would be a large part of the answer, but if anyone has a better idea on a better way to do this, i'm all ears ...


****** EXAMPLE ******

BEFORE processing :
------------------------------------------
<html>   <head>   <title>Untitled Document
</title>
</head><body><table width="400" border="0">
<tr>
<td>&nbsp;
</td><td>&nbsp;</td></tr>
     <tr><td>&nbsp;</td>
<td><table width="100%"  border="1">
  <tr>  <td>&nbsp;</td>  
 
                     <td>&nbsp;</td></tr>                          </table>
  </td>         </tr>        <tr>             <td>&nbsp;</td>
          <td>&nbsp;</td>
     </tr> </table> </body>
</html>

------------------------------------------

AFTER processing :
------------------------------------------
<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<table width="400" border="0">
     <tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
     </tr>
     <tr>
          <td>&nbsp;</td>
          <td>
               <table width="100%"  border="1">
                 <tr>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                     </tr>
                 </table>
          </td>
     </tr>
     <tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
     </tr>
</table>
</body>
</html>Start Free Trial
 
Loading Advertisement...
 
[+][-]10.24.2004 at 11:43PM PDT, ID: 12397775

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Miscellaneous Web Development
Sign Up Now!
Solution Provided By: gnudiff
Participating Experts: 5
Solution Grade: A
 
 
[+][-]10.25.2004 at 07:40AM PDT, ID: 12400645

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]10.25.2004 at 11:50PM PDT, ID: 12408181

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]10.26.2004 at 06:34AM PDT, ID: 12410569

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]10.30.2004 at 01:24PM PDT, ID: 12453660

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]10.30.2004 at 01:27PM PDT, ID: 12453679

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.05.2004 at 06:26AM PST, ID: 12748293

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]12.17.2004 at 09:55PM PST, ID: 12856127

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]12.21.2004 at 02:54AM PST, ID: 12874662

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32