in reply to My regex works, but I want to make sure it's not blind luck
G'day SergioQ,
Your approach to learning and fully understanding what you are doing is very good; and in response to that, you're getting good advice.
However, in this particular case, I don't believe a regex is the right tool for the job. It would be far more efficient to use Perl's built-in string handling functions.
$ perl -E ' my @images = qw{a.png b.gif c.svg d.jpg}; for (@images) { say substr $_, rindex $_, "."; } ' .png .gif .svg .jpg
See the documentation for those: substr and rindex.
Note: if you provide some representative, sample data, I may have additional, or even different, advice.
— Ken
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: My regex works, but I want to make sure it's not blind luck
by Marshall (Canon) on Dec 29, 2020 at 21:19 UTC |