[Tokyo.pm] Perl5.6 での正規表現

simon.p.cozens @ jp.pwcglobal.com simon.p.cozens @ jp.pwcglobal.com
2000年 4月 12日 (水) 00:30:23 CDT


-------------- next part --------------
¥«¥º¥ó¥º¤Ç¤¹¡£

²¬Éô¤µ¤ó¡§
> 5.6¤Ç¶¯²½¤µ¤ì¤¿Àµµ¬É½¸½¤ÎǽÎϤȤ·¤Æ¡¢Àµµ¬É½¸½¤ÎÃæ¤Ë
> Perl¤Î¥³¡¼¥É¤òËä¤á¹þ¤á¤ë¤«¤éXML¤Ç»È¤ï¤ì¤Æ¤¤¤ë¤è¤¦¤Ê
> Âбþ¤¹¤ë¥¿¥°¤ÎÂФ˥ޥåÁ¤¹¤ëÀµµ¬É½¸½¤ò½ñ¤±¤ë

> ¤È¤¤¤¦¤Î¤¬¤¢¤Ã¤¿¤È»×¤¦¤ó¤Ç¤¹¤¬¡¢¤³¤ì¤ÎÎã¤Ï¤É¤³¤«¤Ë
> ¤¢¤ë¤Ç¤·¤ç¤¦¤«¡©

¤³¤ì¤Ï¤É¤¦¡©

use re "eval";
sub p {my $b=1;$_=shift; my $a; s/\n//sg; my $op = qr/<([^>]+?)\s*[^>]*>/;
s{(?{$b=1;})$op(((?:<\1>(?{++$b}))+|(?:<\/\1>(?{--$b}))+|(?{$b}).)+)<\/\1>}
{"\nOPEN (".($a=$1).")\n".p($2)."\nCLOSE ($a)\n"}seg;return $_;}

print p(<<EOF);
   <html>
    <head> Foo </head>
    <body>
        <thing widget=blah> bar </thing>
    </body>
    </html>
EOF

----------------------------------------------------------------
The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material.  Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited.   If you received
 this in error, please contact the sender and delete the material from any
computer.


Tokyo-pm メーリングリストの案内