in reply to Re: Regular expression
in thread Regular expression

I'm on a Solaris machine and tried ([^\\+]) but can't match it at end of line thats why I posted the code here I'll try the split Thank you

Replies are listed 'Best First'.
Re^3: Regular expression
by shmem (Chancellor) on Sep 16, 2008 at 14:05 UTC

    You could use File::Basename, split and tr:

    use File::Basename; $record = "FRAG 1 1 2000000 0 0 0 0 \\\\172.20.13.49\\backup\\rbgmst02 +_dd2\\stu1\\CPOSTA_1221170039_C1_F1 rbgmst02 65536 0 0 -1 0 *NULL* 12 +22379639 1 65537 0 0 0 0 0 0 0"; if($record =~ m|FRAG|) { my $str = (split " ", $record)[8]; $str =~ tr[\\][/]; print basename($str),"\n"; } __END__ CPOSTA_1221170039_C1_F1

    Alternative:

    $record = "FRAG 1 1 2000000 0 0 0 0 \\\\172.20.13.49\\backup\\rbgmst02 +_dd2\\stu1\\CPOSTA_1221170039_C1_F1 rbgmst02 65536 0 0 -1 0 *NULL* 12 +22379639 1 65537 0 0 0 0 0 0 0"; if($record =~ m|FRAG|) { $record =~ /(?<=\\)(\w+)(?:\s|$)/; print "$1\n"; } __END__ CPOSTA_1221170039_C1_F1

    See perlre.