in reply to Regular expression

hi,

If my guess is correct, then follow the below said code:

while (<DATA>) { print "$&\n" if ($_=~/^\/(.+)modem$/); } __DATA__ /1sbc/dasds/sdf/dsd/modem /2sbc/dasds/FSFsdf/dsd/modem1 /3sbc/dasdFDAs/sFDASFdf/dsd/modem /4sbc/dasFSDAds/sdf/dFDsd/modem3

output

/1sbc/dasds/sdf/dsd/modem
/3sbc/dasdFDAs/sFDASFdf/dsd/modem

regards

franklin

Don't put off till tomorrow, what you can do today.

Replies are listed 'Best First'.
Re^2: Regular expression
by Mandrake (Chaplain) on Jun 22, 2006 at 05:54 UTC
    But the requirement was first to match sbc/dasds/sdf/dsd/ absolutely and after that anything starts with "modem".
    Your code matches the occurance of modem as the last string alone which I believe is not what is required.
    my $string ="sbc/dasds/sdf/dsd/modemL" ; if ($string=~/sbc\/dasds\/sdf\/dsd\/modem.*/) { print "Matching" ; }
    should be sufficient.
    Thanks..