Regex - replace all character that is not a letter or number with underscore

11 points
Created by:



Replace with:


Text before regex:

text to test(ooo)replace abc123 efg

Text after regex is applied:


Results screenshot from notepad plus plus

Regex - replace all chars that is not a letter or number with underscore - notepad plus plus screenshot
Notepad++ regex replace result

Alternative regexes

// Alternatively regex can be replaced with:


// what means:
// two or more _ character occurrences 
// or 
// any character that is not A-Z, a-z, 0-9, or _ 
// (\W is shortcat for [^A-Za-z0-9_])

Merged questions

  1. Regex - escape with underscore all characters that are not letter or number

Native Advertising
50 000 ad impressions - 449$
Get your tech brand or product in front of software developers.
For more information contact us:
Red dot
Dirask - friendly IT community for everyone.

❤️💻 🙂