use warnings; use strict; use YAPE::Regex::Explain; my $re = '[\w().-]*\(?([\w.-])?\)?\s*->\s$'; print YAPE::Regex::Explain->new($re)->explain(); __END__
The regular expression: (?-imsx:[\w().-]*\(?([\w.-])?\)?\s*->\s$) matches as follows: NODE EXPLANATION ---------------------------------------------------------------------- (?-imsx: group, but do not capture (case-sensitive) (with ^ and $ matching normally) (with . not matching \n) (matching whitespace and # normally): ---------------------------------------------------------------------- [\w().-]* any character of: word characters (a-z, A- Z, 0-9, _), '(', ')', '.', '-' (0 or more times (matching the most amount possible)) ---------------------------------------------------------------------- \(? '(' (optional (matching the most amount possible)) ---------------------------------------------------------------------- ( group and capture to \1 (optional (matching the most amount possible)): ---------------------------------------------------------------------- [\w.-] any character of: word characters (a-z, A-Z, 0-9, _), '.', '-' ---------------------------------------------------------------------- )? end of \1 (NOTE: because you're using a quantifier on this capture, only the LAST repetition of the captured pattern will be stored in \1) ---------------------------------------------------------------------- \)? ')' (optional (matching the most amount possible)) ---------------------------------------------------------------------- \s* whitespace (\n, \r, \t, \f, and " ") (0 or more times (matching the most amount possible)) ---------------------------------------------------------------------- -> '->' ---------------------------------------------------------------------- \s whitespace (\n, \r, \t, \f, and " ") ---------------------------------------------------------------------- $ before an optional \n, and the end of the string ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------
Do you really need those capturing parentheses? All the examples in the doc show pretty simple regexes for prompt. Maybe you could try simplifying the regex until it passes some simple case.
is throwing an errorWhat is the error message?
In reply to Re: Regex check
by toolic
in thread Regex check
by spivey49
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |