RegexWars
Tier 2 · Archmagereplace

Redact The Key

Star out everything after the sk_live_ prefix, however long the key is, leaving other text untouched.

A replacement string cannot count, so you cannot swap the whole key for a fixed run of asterisks. Replace one character at a time instead, and use a lookbehind to ask "is there a sk_live_ back there?" — JavaScript lookbehinds are not limited to a fixed width, which is what makes this possible at all.

Your pattern0 chars · par 20
//
Flags
Start typing — tests run as you go.0 of 5 visible tests passing
Test cases
  • sk_live_4eC39HqLyjWD→ "sk_live_************"
  • token: sk_live_abc123→ "token: sk_live_******"
  • no secrets here→ "no secrets here"
  • sk_live_a→ "sk_live_*"
  • pk_live_abc123→ "pk_live_abc123"

    publishable keys are meant to be printed

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