RE za behu

Jiri Polcar polcar na physics.muni.cz
Sobota Srpen 30 15:30:11 MEST 2003


    Zdravim,

mam promenou $re, ve ktere je ulozen regularni vyraz. Pak mam promenou
$text, kterou chci proti $re testovat:

    $re   = '/x/';

    $text = 'xyz';

    if ( $text =~ $re )            { print "MATCH\n" } else { print "NO\n" }
    if ( $text =~ /$re/ )          { print "MATCH\n" } else { print "NO\n" }
    if ( eval { $text =~ $re }  )  { print "MATCH\n" } else { print "NO\n" }
    if ( eval { $text =~ /$re/ } ) { print "MATCH\n" } else { print "NO\n" }
    if ( eval '$text =~ '.$re  )   { print "MATCH\n" } else { print "NO\n" }

Teprve posledni radek zabral. Jeste bych se smiril s tim, ze nefunguji
prvni dva radky. Proc ale nepracuji druhy dva?

--
JP


Další informace o konferenci Perl