It's not clear to me what you are trying to achieve. Can you please post some short example strings that should be accepted and ignored, a few of each, indicating which is which?
Update: Your regex is basic enough (i.e., no regex features added after Perl version 5.6) that YAPE::Regex::Explain may be enlightening (update: fixed the regex: added [] as needed per this):
c:\@Work\Perl\monks>perl -wMstrict -le "use YAPE::Regex::Explain; ;; print YAPE::Regex::Explain->new(qr/\b(\s*([a-zA-Z ]+)\s((-?[0-9]){1,2 +})\b)/)->explain; " The regular expression: (?-imsx:\b(\s*([a-zA-Z ]+)\s((-?[0-9]){1,2})\b)) 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): ---------------------------------------------------------------------- \b the boundary between a word char (\w) and something that is not a word char ---------------------------------------------------------------------- ( group and capture to \1: ---------------------------------------------------------------------- \s* whitespace (\n, \r, \t, \f, and " ") (0 or more times (matching the most amount possible)) ---------------------------------------------------------------------- ( group and capture to \2: ---------------------------------------------------------------------- [a-zA-Z ]+ any character of: 'a' to 'z', 'A' to 'Z', ' ' (1 or more times (matching the most amount possible)) ---------------------------------------------------------------------- ) end of \2 ---------------------------------------------------------------------- \s whitespace (\n, \r, \t, \f, and " ") ---------------------------------------------------------------------- ( group and capture to \3: ---------------------------------------------------------------------- ( group and capture to \4 (between 1 and 2 times (matching the most amount possible)): ---------------------------------------------------------------------- -? '-' (optional (matching the most amount possible)) ---------------------------------------------------------------------- [0-9] any character of: '0' to '9' ---------------------------------------------------------------------- ){1,2} end of \4 (NOTE: because you are using a quantifier on this capture, only the LAST repetition of the captured pattern will be stored in \4) ---------------------------------------------------------------------- ) end of \3 ---------------------------------------------------------------------- \b the boundary between a word char (\w) and something that is not a word char ---------------------------------------------------------------------- ) end of \1 ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------
In reply to Re: Help with regular expression
by AnomalousMonk
in thread Help with regular expression
by heman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |