How to allow a regular expression of letters and numbers to accept the cedilla

1

I need the regular expression to accept the ç key.

$('[name="txtEndereco"]').keyup(function () { 
    this.value = this.value.replace(/[^a-zA-Z 0-9]+/g,''); 
});
    
asked by anonymous 14.02.2017 / 22:12

2 answers

4
/[^a-zA-ZçÇ 0-9]+/g

Working with regex in letters with accents is +/- difficult in JavaScript.

In other languages there is class \p{L} which includes all characters that are letters. In JavaScript sometimes it is best to add cases that are accurate.

    
14.02.2017 / 22:42
0

Using [À-ú] takes cedilla, uncle, grave accent, acute accent, caret accent, etc. I had problems and I used this expression, it worked very well.

    
12.01.2018 / 17:12