Common JS regular expressions for matching double byte characters (including Chinese characters)

From , 3 Years ago, written in JavaScript, viewed 97 times.
URL https://pastebin.vip/view/084b6fbb
  1. [^\x00-\xff],可以用来计算字符串的长度(一个双字节字符长度计2,ASCII字符计1),代码示例如下:  
  2. console.info( "abc".replace( /[^\x00-\xff]/g,"aa" ).length ) // 3  
  3. console.info( "汉字".replace( /[^\x00-\xff]/g,"aa" ).length ) // 4  
  4. console.info( "abc汉字".replace( /[^\x00-\xff]/g,"aa").length ) // 7  

Reply to "Common JS regular expressions for matching double byte characters (including Chinese characters)"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website