Re: Looking for a 3rd eye - perl errors
- In reply to: Odhiambo Washington : "Looking for a 3rd eye - perl errors"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 16 Nov 2021 02:56:34 UTC
On 11/15/21 2:00 AM, Odhiambo Washington wrote: > Hi everyone, Hello. :-) > Looking for a 3rd eye here: > > In the code below, I am getting these errors: > $$contref =~ s/^\w+:{1,1}?//gm; <= Error: Useless use of greediness > modifier '?' in regex; marked by <-- HERE in m/^\w+:{1,1}? <-- HERE See 'perldoc perlretut' and "Matching repetitions". You are using two quantifiers next to each other -- {1,1} and ? -- and Perl does not like that. > $uri =~ s/%{?([a-z]+)}?/$param{$1}/g; <======Error: Unescaped left > brace in regex is passed through in regex; marked by <-- HERE in m/%{ <-- > HERE ?([a-z]+)}?/ Again, see 'perldoc perlretut' and "Matching repetitions". Braces are regular expression metacharacters. If you want to match literal braces in your target string, you must escape them: \{ ... \} When writing and/or posting Perl code with regular expressions, it is helpful to include example target strings and expected captures in the comments. If you are serious about regular expressions, "Mastering Regular Expressions" by Jeffrey Friedl is very helpful: http://regex.info/book.html David