简体   繁体   中英

How to make a generic regex expression to validate UTF-8 special characters in input through JS?

function myFunction() {
   var str = "W"; 
   var patt1 = /\u0057/g;
   var result = str.match(patt1);
   document.getElementById("demo").innerHTML = result;

} This function will Search for W character as\W is hexadecimal code for W.

If I try to generalize it with var patt1 =/\\u00[(\\w+)][(\\w+)] /g/; This regex is not working. Why?

I'm using /[az\À-\ſ]/ or /[az\\xC0-\\xff]/

https://regex101.com/r/yNG7rf/1

https://regex101.com/r/yNG7rf/2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM