The regular expression: (?is-mx:^((?:(?!
).|)*?)\n) matches as follows: NODE EXPLANATION ---------------------------------------------------------------------- (?is-mx: group, but do not capture (case-insensitive) (with . matching \n) (with ^ and $ matching normally) (matching whitespace and # normally): ---------------------------------------------------------------------- ^ the beginning of the string ---------------------------------------------------------------------- ( group and capture to \1: ---------------------------------------------------------------------- (?: group, but do not capture (0 or more times (matching the least amount possible)): ---------------------------------------------------------------------- (?! look ahead to see if there is not: ----------------------------------------------------------------------(?:(?!).)*
''
----------------------------------------------------------------------
) end of look-ahead
----------------------------------------------------------------------
. any character
----------------------------------------------------------------------
| OR
----------------------------------------------------------------------
''
----------------------------------------------------------------------
(?: group, but do not capture (0 or more
times (matching the most amount
possible)):
----------------------------------------------------------------------
(?! look ahead to see if there is not:
----------------------------------------------------------------------
'
'
----------------------------------------------------------------------
) end of look-ahead
----------------------------------------------------------------------
. any character
----------------------------------------------------------------------
)* end of grouping
----------------------------------------------------------------------
''
----------------------------------------------------------------------
)*? end of grouping
----------------------------------------------------------------------
) end of \1
----------------------------------------------------------------------
\n '\n' (newline)
----------------------------------------------------------------------
) end of grouping
----------------------------------------------------------------------