A handy tool for understanding complex regexes is YAPE::Regex::Explain
$ perl -e 'use YAPE::Regex::Explain;print YAPE::Regex::Explain->new("^
+(?:https?|ftp):")->explain;'
The regular expression:
(?-imsx:^(?:https?|ftp):)
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):
----------------------------------------------------------------------
^ the beginning of the string
----------------------------------------------------------------------
(?: group, but do not capture:
----------------------------------------------------------------------
http 'http'
----------------------------------------------------------------------
s? 's' (optional (matching the most amount
possible))
----------------------------------------------------------------------
| OR
----------------------------------------------------------------------
ftp 'ftp'
----------------------------------------------------------------------
) end of grouping
----------------------------------------------------------------------
: ':'
----------------------------------------------------------------------
) end of grouping
----------------------------------------------------------------------
-- flounder |