regex pattern to match the end of a string

Use the $ metacharacter to match the end of a string.

In Perl, this looks like:

my $str="red/white/blue";
my($last_match) = $str =~ m/.*\/(.*)$/;

Written in JavaScript, this looks like:

var str="red/white/blue".match(/.*\/(.*)$/);

Leave a Comment