Skip to content

Instantly share code, notes, and snippets.

@davidbarredo
Last active October 7, 2015 09:26
Show Gist options
  • Save davidbarredo/6e00da8f18361302409c to your computer and use it in GitHub Desktop.
Save davidbarredo/6e00da8f18361302409c to your computer and use it in GitHub Desktop.
Util regular expressions
//for positive integers
/^\+?[1-9]\d*$/.test();
//for positive integers and zero
/^\+?(0|[1-9]\d*)$/.test();
//for positive/negative integers and zero
/^\-?(0|[1-9]\d*)$/.test();
//to match specific chars
/[`~!@#$%^&*()_|+\-=÷¿?;:'",.<>\{\}\[\]\\\/]/.test();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment