Latin charcters included in JavaScript Regex

前端 未结 5 1787
礼貌的吻别
礼貌的吻别 2021-02-08 03:06

I\'m looking to included the Latin characters below in a JavaScript regex for a string validation.

ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏàáâãäåæçèéêëìíîïÐÑÒÓÔÕÖØÙÚÛÜÝÞßðñòóôõöøùúûüýþÿ         


        
5条回答
  •  一向
    一向 (楼主)
    2021-02-08 03:36

    I'm using:

    /^[A-z\u00C0-\u00ff\s'\.,-\/#!$%\^&\*;:{}=\-_`~()]+$/
    

    as regular expression

    var regexp = /[A-z\u00C0-\u00ff]+/g,
      ascii = ' hello !@#$%^&*())_+=',
      latin = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏàáâãäåæçèéêëìíîïÐÑÒÓÔÕÖØÙÚÛÜÝÞßðñòóôõöøùúûüýþÿ',
      chinese = ' 你 好 ';
    
    console.log(regexp.test(ascii)); // true
    console.log(regexp.test(latin)); // true
    console.log(regexp.test(chinese)); // false
    

    Glist: https://gist.github.com/germanattanasio/84cd25395688b7935182

提交回复
热议问题