Remove accents/diacritics in a string in JavaScript

前端 未结 29 2574
轻奢々
轻奢々 2020-11-21 13:29

How do I remove accentuated characters from a string? Especially in IE6, I had something like this:

accentsTidy = function(s){
    var r=s.toLowerCase();
           


        
29条回答
  •  一个人的身影
    2020-11-21 13:44

    You can create regex's in multiple ways. Using the new RegExp-constructor:

    var re = new RegExp("[a-z]", "ig") //(string pattern, string modifiers)
    

    Or using the regex literal notation:

    var re = /[a-z]/ig; // /pattern/modifiers
    

    You have mixed the two.

提交回复
热议问题