Created
December 20, 2016 17:41
-
-
Save MarQuisKnox/f43cc11c3725e93062c5270a71b62916 to your computer and use it in GitHub Desktop.
Check If a String is a Valid Array
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
/** | |
* Determine if a string | |
* is a valid array | |
* | |
* @param string string | |
* @return boolean | |
*/ | |
function isValidArray( string ) | |
{ | |
var pattern = /^\[('|")?[A-Za-z0-9]+('|")?(((,(\s+)?('|")?[A-Za-z0-9]+('|")?)+)?)\]$/ig; | |
return pattern.test( string ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TODO: