I don't understand why my $3 includes the slash and everything after and not just "to"?
Thanks for any advice!
#!/usr/bin/perl use strict; use warnings; $a = "some/path/to/somewhere/hello"; if ($a =~ /(.+)(\/path\/)(.+)(\/.+)/) { print "$1 -> $3\n"; } Output: some -> to/somewhere
In reply to Regex help by yoda54
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |