Given a string that looks suspiciously like a path name:
'/a/b/c/d/e/abc00000'
yet is not a path name, I am trying to extract the
abc000000 identifier from the end. My regex doesn't work, and while I know how to write a better one that works, I don't know specifically why this one does not:
my $s = '/a/b/c/d/e/abc00000';
my ($id) = $s =~ m{/(.+?\d+)$};
print $id, "\n";
__OUTPUT__
a/b/c/d/e/abc00000
I can fix it easily by using:
my ($id) = $s =~ m{/([^/]+\d+)$};
Which I understand. It's just that I don't understand why the first version is greedy.