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

Checkout latest findings & news:

Checkout latest questions:

Checkout latest wiki articles:

Hey 👋
Would you like to know what we do?
  • Dirask is a friendly IT community for learners, professionals and hobbyists to share their knowledge and help each other in extraordinary easy way.
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.
Rockstar community members
Thank you for great work 👍