RegexWars
Tier 5 · Conjurercapture

Stop At The First One

Capture everything before the FIRST equals sign: key=value=other gives key.

.* is greedy — it takes the whole string and hands characters back only as far as it must, so (.*)= lands on the LAST equals sign and gives you key=value. Two fixes, both worth knowing: make the quantifier lazy with (.*?)=, or say what you actually mean with a negated class, ([^=]+)=, which cannot cross an equals sign in the first place. The second is usually both shorter and faster. A string with no equals sign at all must not match.

Your pattern0 chars · par 8
//
Flags
Start typing — tests run as you go.0 of 4 visible tests passing
Test cases
  • name=william→ ["name"]
  • path=/usr/local→ ["path"]
  • timeout=30→ ["timeout"]
  • novaluemust not match

    no separator, nothing to split

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