I want to write a regex to remove all non alpha characters, as follows:
björn -> björn
Barry's -> barrys
Who? -> who
Cibé? -> cibé
I'd -> id
ice-cream -> icecream
No!!! -> no
[{brackets}] -> brackets
~inv3rse -> invrse
and to convert all characters to their lowercase versions. How do I do this for all languages or at least for European languages using the Latin script?
str.toLowerCase().replace(/[^a-z]/gi,'');
this will convert everything to lowercase, then replace everything that isn't an alphabetic character (a-z) to the empty string, essentially removing them. in order to keep certain other characters (like e with an accent mark) just add that symbol to the regex.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With