Regular expression for all printable characters in JavaScript

前端 未结 4 1736
时光说笑
时光说笑 2020-11-27 20:33

Looking for a regular expression for that validates all printable characters. The regex needs to be used in JavaScript only. I have gone through this post but it mostly talk

4条回答
  •  悲&欢浪女
    2020-11-27 20:42

    Looks like JavaScript has changed to some degree since this question was posted?

    I'm using this one:

    var regex = /^[\u0020-\u007e\u00a0-\u00ff]*$/;
    console.log( regex.test("!\"#$%&'()*+,-./:;<=>?@[] ^_`{|}~")); //should output "true" 
    console.log( regex.test("Iñtërnâtiônàlizætiøn")); //should output "true"
    console.log( regex.test("☃

提交回复
热议问题