Tomtom has asked for the wisdom of the Perl Monks concerning the following question:
Hello everyone,
I have an array of strings, and for each string, I would like to match it with a regex.
I wondered if there was some kind of module or something, that could tell me, if the string doesn't match, the reason why it didn't match, and at what point ( was it just one character not matching, or was the string totally different, or ... ).
I hope my question was clear enough :)
Thanks for your answers
Tomtom
Re: regex checking
by Hena (Friar) on May 26, 2005 at 08:44 UTC
|
Well by using use re "debug"; you will get info printed on how the regex tries to match something. It will print both successes and failures and can be quite lenghty. And something similar is this Yape-Regex-Explain module (haven't used myself). | [reply] [d/l] |
|
Thank you :)
I'll take a look at this.
| [reply] |
Re: regex checking
by Joost (Canon) on May 26, 2005 at 09:40 UTC
|
Unless you're using really perl-specific regexes, Regex Coach can be instructive.
| [reply] |
Re: regex checking
by blazar (Canon) on May 26, 2005 at 08:32 UTC
|
I hope my question was clear enough :)
Indeed it is clear enough. However I'm not sure it is well posed. More precisely, I'm far from being a regex expert, but I strongly doubt that for a generic regex there would be a unique way not to match a given string.
| [reply] |
|
In fact, that regex I'm applying on the strings in the array is a sort of filter, so I was wondering if there was a way to know why a string or another didn't match, and at which position in the string it didn't match.
| [reply] |
|