in reply to regex to match a literal dot near end of string

Close, but because there could be multiple, you need to use * for extra-greedyness :

sub new_filename { my ($name,$platform) = @_; $name =~ /^(.*)(\..+)$/ or die "$name is an invalid patch name"; "$1.$platform$2"; }
Thst should work, + is just not greedy enough
OH, a sarcasm detector, that’s really useful

Replies are listed 'Best First'.
Re: Re: regex to match a literal dot near end of string
by japhy (Canon) on Jul 18, 2001 at 20:39 UTC
    No, + and * are equally greedy. The former just requires at least one character to match, while the latter does not.

    _____________________________________________________
    Jeff japhy Pinyan: Perl, regex, and perl hacker.
    s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

      <braindead> Not sure what i meant, when i think , i knew that. Sorry 'bout that </braindead>
      OH, a sarcasm detector, that’s really useful