in reply to Explain regex ?: usage in grouping

/^\s*(?:#|$)/

is the same as

/^\s*#/ || /^\s*$/

while

/^\s*#|$/

is the same as

/^\s*#/ || /$/