in reply to Re: Regex to Array lookup question
in thread Regex to Array lookup question
$icon =~ s/https:\/\/api.weather.gov\/icons\/land\///;
This substitution needs more backslashes (escapes)! (Never thought I'd say that.) The regex . (dot) operator matches, by default, any character except a newline. E.g.:
To match only a period, escape the dot metacharacters:c:\@Work\Perl\monks>perl -wMstrict -le "my $icon = 'https://apiXweatherXgov/icons/land/fooble'; $icon =~ s/https:\/\/api.weather.gov\/icons\/land\///; print qq{'$icon'}; " 'fooble'
BTW: One way to cut down on escapes in a regex is by the wise choice of a regex delimiter. E.g.:
$icon =~ s{https://api\.weather\.gov/icons/land/}{};
Please see perlre, perlretut, and perlrequick.
Give a man a fish: <%-{-{-{-<
|
|---|