Regex Replace and Transform
Rewrite text with group references and replacer functions.
- regex replace
- re.sub
- group reference
- strip html
- replacer function
Regex Replace and Transform
Rewrite text with group references and replacer functions.
Commands
| Command | What it does |
|---|---|
swap groups in JS | Use dollar-1 references in replace |
swap groups in Python | Use backslash-1 in re.sub |
collapse whitespace | Replace runs of spaces with one |
strip simple tags | Remove angle-bracket markup |
function replacer | Compute replacements with code |
Example
'2026-10-11'.replace(/(\d{4})-(\d{2})-(\d{2})/, '$3/$2/$1')
FAQ
Why did my group reference insert literally?
The pattern had no such group, or you used a non-capturing group - count groups or switch to named ones.
Is stripping HTML with regex safe?
Only for trivial snippets; nested markup needs a real parser.
الأسئلة الشائعة
Why did my group reference insert literally?
The pattern had no such group, or you used a non-capturing group - count groups or switch to named ones.
Is stripping HTML with regex safe?
Only for trivial snippets; nested markup needs a real parser.