my $string = "abcd-ef1"; my @matches = $string =~ /^(\w{2})?(\d)?(\w{2})?(-)?(\w{2})?(\d)?$/; my $errors = grep { !defined $_ } @matches; print "Errors is $errors\n"; ---- Errors is 1
Basically, you're expecting everything to match. If it doesn't, then non-matches are errors. You'll have to fiddle with it, I think, to get it to do exactly what you want, but that should give you a good start. (This is, of course, that you have to (re)invent the wheel.)
------
We are the carpenters and bricklayers of the Information Age.
The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6
Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.
In reply to Re3: Fuzzy Matching
by dragonchild
in thread Fuzzy Matching
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |