Mask bearer tokens in logs.
Section: JavaScript Recipes
Redact bearer token
javascript
javascript
text.replace(/\bBearer\s+[A-Za-z0-9._-]+\b/g, "Bearer [REDACTED]")Explanation
Useful when sanitizing output.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing JavaScript Recipes
Collapse internal whitespace
Normalize repeated whitespace down to single spaces.
Basic semver parser
Extract version parts from a semantic version string.