[Boston.pm] more specific regex error messages?
email-2Ro/Dj86MvDSUeElwK9/[email protected] Fri, 25 Feb 2022 12:19:10 -0600
| Newsgroups | gmane.comp.lang.perl.perl-mongers.boston |
|---|---|
| Message-ID | <[email protected]> |
I have a rather complex regex that I'm throwing text at.
if($str=~m/\Athing1\:thing2\,thing3\@(\w+)\?(\d+)\Z/){
# process str
} else {
die "bad str 'str' ";
}
Is there a way to get better built in reporting with regexps?
with the above, if the string doesn't match, I get "bad input".
What I'd rather get is something like "expecting \:thing2"
if need be, I'll break it into a series of nested ifs.
but that would be exceedingly ugly.
The pattern does not require backtracking.
I've already checked that I'm in a certain location and only one kind of
input is expected.
and again, I can't load external modules at work.
suggestions?
Greg