Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Parsing Table

by prasadbabu (Prior)
on Aug 17, 2010 at 09:42 UTC ( #855447=note: print w/ replies, xml ) Need Help??


in reply to Parsing Table

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)&dagger; <Tr;;4><ems>Females (SD) <26> 48.26 (2.36)&dagger; <Tr;;4><ems>U&Dagger; <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;

Prasad


Comment on Re: Parsing Table
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://855447]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (7)
As of 2014-10-25 23:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (149 votes), past polls