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

Re^2: Regex problem while parsing tagged, hierarchical data

by Mago (Parson)
on Sep 19, 2006 at 11:25 UTC ( [id://573688]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    
    perl -pi -e 'if(/<level1(\sid=\".*\")>/){$a=$1};if(/<level2>/){$_=~s/(
    +<level2)>/$1$a>/g}' input
    ...
    
    perl -pi -e '$a=m;(<level(1|2))(\sid=\".*\")*>;;$a?$2==1?$b=$3:$_=~s;(
    +$1);$1$b;g:1;' input
    
  2. or download this
    
    perl -pi -e 'm;(<level(1|2))(\sid=\".*\")*>;;$&?$2==1?$b=$3:$_=~s;($1)
    +;$1$b;g:1;' input
    
  3. or download this
    
    perl -pi -e 'm;(<level(1|2))(\sid=\".*\")*>;;$&?$2==1?$b=$3:$_=~s;($1)
    +;$1$b;g:1' input
    
  4. or download this
    
    perl -pi -e '/l1(\sid=.*)>/?$a=$1:s;l2>;l2$a>;' input
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (6)
As of 2024-04-24 12:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found