Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
Perl: the Markov chain saw
 
PerlMonks  

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

by Mago (Parson)
on Sep 19, 2006 at 12:57 UTC ( #573705=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Regex problem while parsing tagged, hierarchical data
in thread Regex problem while parsing tagged, hierarchical data

Ups !! -1 char

perl -pi -e '/(<level(1|2))(\sid=\".*\")*>/;$&?$2==1?$b=$3:$_=~s;($1); +$1$b;g:1' input


Mago
mago@rio.pm.org



Comment on Re^4: Regex problem while parsing tagged, hierarchical data
Download Code
Re^5: Regex problem while parsing tagged, hierarchical data
by smokemachine (Hermit) on Sep 19, 2006 at 13:14 UTC
    perl -pi -e '/(<level(1|2))( id=\".*\")*>/;$&?$2==1?$b=$3:$_=~s;($1);$1$b;g:1' input
      perl -pi -e '/1 id="(.*)"/?$ci=$1:s/2>/2 id="$ci">/g' input
      (:


      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      "one who asks a question is a fool for five minutes; one who does not ask a question remains a fool forever."

      mk at perl dot org dot br
        33 chars !
        perl -pi -e '/l1(\sid=.*)>/?$a=$1:s;l2>;l2$a>;' input


        Mago
        mago@rio.pm.org


Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2014-04-21 06:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (492 votes), past polls