'(?^:((?i)([+-]?)((?=[.]?[0123456789])([0123456789]*)(?:([.])([0123456
+789]{0,}))?)(?:([E])(([+-]?)([0123456789]+))|)))
| [reply] [d/l] |
c:\@Work\Perl\monks>perl -wMstrict -le
"use Regexp::Common qw(RE_num_real);
use YAPE::Regex::Explain;
;;
print YAPE::Regex::Explain->new(RE_num_real(-keep, -group=>3, -sep=>'
+,', -base=>2))->explain;
"
The regular expression:
(?-imsx:((?i)([+-]?)((?=[.]?[0123456789])([0123456789]*)(?:([.])([0123
+456789]{0,}))?)(?:([E])(([+-])([0123456789]+))|)))
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):
----------------------------------------------------------------------
( group and capture to \1:
----------------------------------------------------------------------
(?i) set flags for this block (case-
insensitive) (with ^ and $ matching
normally) (with . not matching \n)
(matching whitespace and # normally)
----------------------------------------------------------------------
( group and capture to \2:
----------------------------------------------------------------------
[+-]? any character of: '+', '-' (optional
(matching the most amount possible))
----------------------------------------------------------------------
) end of \2
----------------------------------------------------------------------
( group and capture to \3:
----------------------------------------------------------------------
(?= look ahead to see if there is:
----------------------------------------------------------------------
[.]? any character of: '.' (optional
(matching the most amount possible))
----------------------------------------------------------------------
[0123456789] any character of: '0', '1', '2',
'3', '4', '5', '6', '7', '8', '9'
----------------------------------------------------------------------
) end of look-ahead
----------------------------------------------------------------------
( group and capture to \4:
----------------------------------------------------------------------
[0123456789]* any character of: '0', '1', '2',
'3', '4', '5', '6', '7', '8', '9' (0
or more times (matching the most
amount possible))
----------------------------------------------------------------------
) end of \4
----------------------------------------------------------------------
(?: group, but do not capture (optional
(matching the most amount possible)):
----------------------------------------------------------------------
( group and capture to \5:
----------------------------------------------------------------------
[.] any character of: '.'
----------------------------------------------------------------------
) end of \5
----------------------------------------------------------------------
( group and capture to \6:
----------------------------------------------------------------------
[0123456789] any character of: '0', '1', '2',
{0,} '3', '4', '5', '6', '7', '8', '9'
(at least 0 times (matching the
most amount possible))
----------------------------------------------------------------------
) end of \6
----------------------------------------------------------------------
)? end of grouping
----------------------------------------------------------------------
) end of \3
----------------------------------------------------------------------
(?: group, but do not capture:
----------------------------------------------------------------------
( group and capture to \7:
----------------------------------------------------------------------
[E] any character of: 'E'
----------------------------------------------------------------------
) end of \7
----------------------------------------------------------------------
( group and capture to \8:
----------------------------------------------------------------------
( group and capture to \9:
----------------------------------------------------------------------
[+-]? any character of: '+', '-'
(optional (matching the most
amount possible))
----------------------------------------------------------------------
) end of \9
----------------------------------------------------------------------
( group and capture to \10:
----------------------------------------------------------------------
[0123456789] any character of: '0', '1', '2',
+ '3', '4', '5', '6', '7', '8', '9'
(1 or more times (matching the
most amount possible))
----------------------------------------------------------------------
) end of \10
----------------------------------------------------------------------
) end of \8
----------------------------------------------------------------------
| OR
----------------------------------------------------------------------
) end of grouping
----------------------------------------------------------------------
) end of \1
----------------------------------------------------------------------
) end of grouping
----------------------------------------------------------------------
Please also see perlre, perlretut, and perlrequick. There are also a number of on-line regex explainers, but I'm not familiar enough with them to recommend any particular one. (Update: Actually, davido has a nice regex tester which ends up giving a fair amount of explanation, or at least enlightenment. See his personal node for a link)
Update: Caution: YAPE::Regex::Explain only supports regex features added through Perl version 5.6.
Give a man a fish: <%-{-{-{-<
| [reply] [d/l] [select] |
| [reply] |