RegexWars
Tier 5 · Conjurerextract

Commented Out

From a config file, extract every whole line that is commented out — every line beginning with a #. Inline comments on the end of a real setting do not count.

Without the m flag, ^ means the start of the whole string and $ the end of it, so a pattern anchored with ^ can only ever match once, on line one. The m flag makes both of them mean the start and end of a LINE. Note what that buys you here: dropping the anchor entirely and matching #.* would drag in every inline comment too.

Your pattern1 chars · par 6
//g
Flags
Start typing — tests run as you go.0 of 3 visible tests passing
Test cases
  • # onetwo# three→ ["# one", "# three"]
  • a = 1 # inline# real→ ["# real"]

    the inline comment is not a commented-out line

  • no comments→ []

+ 5 hidden tests, checked when you submit. They are what stops a pattern that only fits the examples above.