JavaScript + Unicode regexes

前端 未结 11 1113
星月不相逢
星月不相逢 2020-11-21 05:11

How can I use Unicode-aware regular expressions in JavaScript?

For example, there should be something akin to \\w that can match any code-point in Lette

11条回答
  •  南方客
    南方客 (楼主)
    2020-11-21 05:57

    You can also use:

    function myFunction() {
      var str = "xq234"; 
      var allowChars = "^[a-zA-ZÀ-ÿ]+$";
      var res = str.match(allowChars);
      if(!str.match(allowChars)){
        res="true";
      }
      else {
        res="false";
      }
      document.getElementById("demo").innerHTML = res;
    

提交回复
热议问题