유용한 Javascript RegEx
ref : http://ntt.cc/2008/05/10/over-10-useful-javascript-regular-expression-functions-to-improve-your-web-applications-efficiency.html
2 | var isNonblank_re = /\S/; |
3 | function isNonblank (s) { |
4 | return String (s).search (isNonblank_re) != -1 |
2 | var isWhole_re = /^\s*\d+\s*$/; |
4 | return String(s).search (isWhole_re) != -1 |
2 | var isInteger_re = /^\s*(\+|-)?\d+\s*$/; |
3 | function isInteger (s) { |
4 | return String(s).search (isInteger_re) != -1 |
2 | var isDecimal_re = /^\s*(\+|-)?((\d+(\.\d+)?)|(\.\d+))\s*$/; |
3 | function isDecimal (s) { |
4 | return String(s).search (isDecimal_re) != -1 |
2 | var isCurrency_re = /^\s*(\+|-)?((\d+(\.\d\d)?)|(\.\d\d))\s*$/; |
3 | function isCurrency (s) { |
4 | return String(s).search (isCurrency_re) != -1 |
2 | var isEmail_re = /^\s*[\w\-\+_]+(\.[\w\-\+_]+)*\@[\w\-\+_]+\.[\w\-\+_]+(\.[\w\-\+_]+)*\s*$/; |
4 | return String(s).search (isEmail_re) != -1; |
phone number check : /^(\([0-9]{3}\)|[0-9]{3}-)([0-9]{3}|[0-9]{4})-[0-9]{4}$/.test('011-1111-2222');