Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

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;


Comment on Re: Parsing Table
Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2015-07-02 01:34 GMT
Find Nodes?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...

    Results (25 votes), past polls