in reply to Pattern matching
This
will give you what you want. Alternatively,my $last_one = ( split, /\\\\/, $string )[ -1 ]
comes to mind, but it looks more complicated that it ought to be (this is largely because it is trying to accommodate the possibility that the desired string contain a single embedded backslash). I prefer the first (split) option over the second.my $last_one = ( $string =~ /([^\\](?!.*\\).*)$/ )[ 0 ];
Update: Fixed original regexp, which incorrectly included a single backslash at the start of the returned string.
the lowliest monk
|
|---|