Languages
[Edit]
EN

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

11 points
Created by:
Frida-Timms
667

Regex: 

(_)+|[^0-9A-Za-z]

Replace with:

_

Text before regex:

text to test(ooo)replace abc123 efg

Text after regex is applied:

text_to_test_ooo_replace_abc123_efg

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:

_+|\W

// 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_])

 

Alternative titles

  1. Npp - regex to replace all character that is not a letter or number with underscore (Notepad++ / Plus Plus)
  2. regex replace all non alphanumeric characters
  3. Regex - escape with underscore all characters that are not letter or number
  4. regex replace all non alphanumeric characters dirask
  5. dirask replace all chars that are not letters regex
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Regex

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join