in reply to perl pattern match for end of string using STDIN and chomp
#!/usr/bin/perl print "get some string: "; chomp($string = <STDIN>); #$string = $ARGV[0]; #chomp($string); $string =~ m/\/([[:alnum:]]+)_.*\.(.+)$/; print "$1\n"; $type = $2; print "$type\n"; $string =~ m/(.+)\.${type}$/; #$string =~ m/(.+)\.${type}\Z/; #$string =~ m/(.+)\.${type}\z/; #$string =~ m/(.+)\.${type}/; print "$1\n"; exit 0;
~/sandbox$ perl junk.pl get some string: /xxxx/yyyy/ZZZ_xxxx.CCC ZZZ CCC /xxxx/yyyy/ZZZ_xxxx
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: perl pattern match for end of string using STDIN and chomp
by cbolcato (Novice) on Oct 08, 2009 at 19:04 UTC | |
by ikegami (Patriarch) on Oct 08, 2009 at 19:09 UTC | |
by kennethk (Abbot) on Oct 08, 2009 at 19:17 UTC | |
by cbolcato (Novice) on Oct 08, 2009 at 19:31 UTC |