Created
December 12, 2011 09:14
-
-
Save piscis/1466115 to your computer and use it in GitHub Desktop.
Match ASCII chars via RegularExpression in Javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Small regular expression to match ASCII-chars between 32-126 | |
* | |
* For a conversion table for ASCII chars see: | |
* http://de.wikipedia.org/wiki/American_Standard_Code_for_Information_Interchange | |
*/ | |
var expr = /([\x20-\x7E]{1,})/gi; | |
var testString = "Foo Bar Barz"; | |
var testString2 = "Foo Bar\tBarz"; | |
// Test | |
console.log(testString.match(expr)[0]===testString); // is true; | |
console.log(testString2.match(expr)[0]===testString2); // is false; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment