We’re all scratching our heads on this one. We’re trying to figure out what this does:
~(?>.*?(?<!\w{3})(?ix) \s(\S)w(?:he|gf|\x{0159})(?-i:MuG)0V(\w\d))Sb4(?=[[:xdigit:]])\2\1
We’re all scratching our heads on this one. We’re trying to figure out what this does:
~(?>.*?(?<!\w{3})(?ix) \s(\S)w(?:he|gf|\x{0159})(?-i:MuG)0V(\w\d))Sb4(?=[[:xdigit:]])\2\1
Straight from YAPE::Regex::Explain by my pal japhy:
(?-imsx:~(?>.*?(?<!w{3})(?ix) s(S)w(?:he|gf|?)(?-i:MuG)0V(wd))Sb4(?=[[:xdigit:]]))
matches as follows:
NODE EXPLANATION
----------------------------------------------------------------------
(?-imsx: group, but do not capture (case-sensitive)
(with ^ and $ matching normally) (with . not
matching
) (matching whitespace and #
normally):
----------------------------------------------------------------------
~ << '~'
----------------------------------------------------------------------
(?> << match (and do not backtrack afterwards):
----------------------------------------------------------------------
.*? <<<< any character except
(0 or more times
<<<< (matching the least amount possible))
----------------------------------------------------------------------
(?<! <<<< look behind to see if there is not:
----------------------------------------------------------------------
w{3} <<<<<< 'w' (3 times)
----------------------------------------------------------------------
) <<<< end of look-behind
----------------------------------------------------------------------
(?ix) <<<< set flags for this block (case-
<<<< insensitive) (disregarding whitespace
<<<< and comments) (with ^ and $ matching
<<<< normally) (with . not matching
)
----------------------------------------------------------------------
s <<<< 's'
----------------------------------------------------------------------
( <<<< group and capture to \1:
----------------------------------------------------------------------
S <<<<<< 'S'
----------------------------------------------------------------------
) <<<< end of \1
----------------------------------------------------------------------
w <<<< 'w'
----------------------------------------------------------------------
(?: <<<< group, but do not capture:
----------------------------------------------------------------------
he <<<<<< 'he'
----------------------------------------------------------------------
| <<<<< OR
----------------------------------------------------------------------
gf <<<<<< 'gf'
----------------------------------------------------------------------
| <<<<< OR
----------------------------------------------------------------------
? <<<<<< '?'
<<<<<< '
----------------------------------------------------------------------
) <<<< end of grouping
----------------------------------------------------------------------
(?-i: <<<< group, but do not capture (disregarding
<<<< whitespace and comments) (case-
<<<< sensitive) (with ^ and $ matching
<<<< normally) (with . not matching
):
----------------------------------------------------------------------
MuG <<<<<< 'MuG'
----------------------------------------------------------------------
) <<<< end of grouping
----------------------------------------------------------------------
0V <<<< '0V'
----------------------------------------------------------------------
( <<<< group and capture to \2:
----------------------------------------------------------------------
wd <<<<<< 'wd'
----------------------------------------------------------------------
) <<<< end of \2
----------------------------------------------------------------------
) << end of look-ahead
----------------------------------------------------------------------
Sb4 << 'Sb4'
----------------------------------------------------------------------
(?= << look ahead to see if there is:
----------------------------------------------------------------------
[[:xdigit:]] <<<< any character of: hexadecimal digits (a-
<<<< f, A-F, 0-9)
----------------------------------------------------------------------
) << end of look-ahead
----------------------------------------------------------------------
<< ' '
----------------------------------------------------------------------
) end of grouping
----------------------------------------------------------------------