Hi tej,
As marto said it is always good to use parsers to have neat solution. Anyhow you have not given your exact output, so below code may satisfy your requirement.
$str = '<Tr><Tc>PA Group (N <26> 23)<Tc>COM Group (N <26> 24)<Tc>
<Tr>Gender<Tc><Tc><Tc><124><sup>2<reset> test <26> 0.216, <mdit>df<med
+> <26> 1, <mdit>P<med> <26> 0.642
<Tr><ems>Male (%)<Tc>14<ths>(60.9)<Tc>13<ths>(54.2)<Tc>
<Tr><ems>Female (%)<Tc>9<ths>(39.1)<Tc>11<ths>(45.8)<Tc>
<Tr>Ethnicity<Tc><Tc><Tc><124><sup>2<reset> test <26> 24.99, <mdit>df<
+med> <26> 4, <mdit>P<med> <178> 0.001
<Tr><ems>African American (%)<Tc>5<ths>(21.7)<Tc>2<ths>(8.3)<Tc>
<Tr><ems>European American (%)<Tc>5<ths>(21.7)<Tc>17<ths>(70.8)<Tc>
<Tr><ems>Asian American (%)<Tc>0<Tc>4<ths>(16.7)<Tc>
<Tr><ems>Hispanic American (%)<Tc>0<Tc>1<ths>(4.2)<Tc>
<Tr><ems>Other (%)<Tc>9<ths>(39.1)<Tc>0<Tc>
<Tr>Age, yr (SD)<Tc>46.05<ths>(6.13)<Tc>30.35<ths>(10.85)<Tc><mdit>t<m
+ed> <26> 5.94, <mdit>P<med> <178> 0.001
<Tr>Education, yr (SD)<Tc>11.37<ths>(2.31)<Tc>15.85<ths>(1.75)<Tc><mdi
+t>t<med> <26> 7.41, <mdit>P<med> <178> 0.001
<Tr>Pain Threshold, <28>C (SD)<Tc>48.75<ths>(2.44)<Tc>47.33<ths>(3.24)
+<Tc>U* <26> 158.0, <mdit>P<med> <26> 0.012
<Tr;;4><ems>Males (SD) <26> 47.77 (3.35)†
<Tr;;4><ems>Females (SD) <26> 48.26 (2.36)†
<Tr;;4><ems>U‡ <26> 244, <mdit>P<med> <26> 0.582<endtab>';
$str = qr{$str};
while ($str =~ m|((<Tr(?:\;)*(?:\d)*>)([^\n]*)<Tc>)|g){
push (@cells, $1)
}
print @cells;
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|