Regex Power Moves

  • \d+ Match any number (123, 4567, etc.)
  • (\w+)@(\w+) Capture groups → use $1, $2 in replace
  • ^|$ Start/end of line (add prefix/suffix to every line)
  • \s+ Any whitespace (spaces, tabs, newlines)

Common Transformations

  • snake_case → camelCase: Search '_([a-z])' → Replace with captured uppercase
  • Remove HTML tags: Search '<[^>]+>' → Replace with empty string
  • Format phone numbers: Search '(\d{3})(\d{3})(\d{4})' → '($1) $2-$3'
  • Trim trailing whitespace: Search '\s+$' → Replace with nothing
  • Double-space to single: Search ' +' → Replace with single space

Bulk Editing Saves Hours

  • Rename variables across a codebase (with case sensitivity ON)
  • Convert CSV columns: 'John,Doe' → 'Doe, John' using capture groups
  • Add quotes around values: Search '(\w+)' → Replace '"$1"'
  • Fix date formats: '12/25/2024' → '2024-12-25' with regex groups
  • Remove duplicate blank lines: Search '\n\n+' → Replace '\n\n'

Options Explained

  • Regex mode: Enables pattern matching (off = literal text search)
  • Case sensitive: OFF: 'hello' matches 'Hello', 'HELLO'. ON: exact match only
  • Global: ON: Replace ALL matches. OFF: Replace only the first match