EN
Regex - replace all character that is not a letter or number with underscore
11 points
Regex:
xxxxxxxxxx
1
(_)+|[^0-9A-Za-z]
Replace with:
xxxxxxxxxx
1
_
Text before regex:
xxxxxxxxxx
1
text to test(ooo)replace abc123 efg
Text after regex is applied:
xxxxxxxxxx
1
text_to_test_ooo_replace_abc123_efg
Results screenshot from notepad plus plus
xxxxxxxxxx
1
// Alternatively regex can be replaced with:
2
3
_+|\W
4
5
// what means:
6
// two or more _ character occurrences
7
// or
8
// any character that is not A-Z, a-z, 0-9, or _
9
// (\W is shortcat for [^A-Za-z0-9_])
Alternative titles
- Npp - regex to replace all character that is not a letter or number with underscore (Notepad++ / Plus Plus)
- regex replace all non alphanumeric characters
- Regex - escape with underscore all characters that are not letter or number
- regex replace all non alphanumeric characters dirask
- dirask replace all chars that are not letters regex