Skip to content

Instantly share code, notes, and snippets.

Created April 27, 2012 09:07
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/2507667 to your computer and use it in GitHub Desktop.
Save anonymous/2507667 to your computer and use it in GitHub Desktop.
RegExp creation
var REGEX = {
NUMBER : /^-?[0-9]*\.?[0-9]+$/,
KEYWORD : /^(?:top\s+|bottom\s+)?(?:right|left)|(?:right\s+|left\s+)?(?:top|bottom)$/
};
var direction = RegExp([
'^(?:',
REGEX.NUMBER.source.slice(1, -1),
'|',
'(?:', REGEX.KEYWORD.source.slice(1, -1), ')deg',
'|',
0,
')$'].join(''));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment