While working with regular expressions today I stumbled over regular expressions 101. Not only does it test your regular expression as you type, but it also picks it apart and explains it to you piece by piece. Amazing!
(?imnx) #multiline mode, explicit captures only, with comments
^ #start at beginning
\s* #optional whitespace
( #start optional group
( #begin OR
(part|item|exhibit|note) #match from a specific set of words
| # OR
(?<unknown>\w+) #match any old word
) #end OR
\s{1,2} #limited whitespace between each one. capture certain specific ones.
)? #end optional group
\(? # optional open parenthesis
( # begin OR
([\d]{1,2}\w?) # 1-2 numbers with an optional letter on the end
| # OR
([ivx]{1,3}) # 1-2 roman numeral letters
| # OR
([a-z]) # 1 letters
) # end OR
\)? # optional end paren
\s{0,2} # optional whitespace
( # begin OR
([\.](?(unknown)(\s{2,})|(\s+))) # a period followed by at least one space if no unknown header, at least two spaces if unknown header
| # OR
([:]\s+) # colon followed by at least one space
| # OR
(\p{Pd}+) # some number of dashes
| # OR
(\)\s+) # close paren followed by at leaset one space
) # end OR
\s* #optional whitespace...
At least it's commented... right?
On the right, you mean

Original address: https://www.donationcoder.com/forum/index.php?topic=38755.0