¡@

Home 

2014/10/16 ¤W¤È 12:06:14

jquery Programming Glossary: pattern.charcodeat

Fastest method for testing a fixed phone number pattern

http://stackoverflow.com/questions/16338714/fastest-method-for-testing-a-fixed-phone-number-pattern

12 return false var i 0 code while i 12 code pattern.charCodeAt i if i 8 i 4 3 if code 48 code 57 return false else if code.. function tecjam5 pattern var c return pattern.length 12 c pattern.charCodeAt 2 3 6 c 1 28 c pattern.charCodeAt 4 3 6 c 1 28 c pattern.charCodeAt.. pattern.length 12 c pattern.charCodeAt 2 3 6 c 1 28 c pattern.charCodeAt 4 3 6 c 1 28 c pattern.charCodeAt 11 1 28 c 3 6 c pattern.charCodeAt..

Fastest method for testing a fixed phone number pattern

http://stackoverflow.com/questions/16338714/fastest-method-for-testing-a-fixed-phone-number-pattern

is my current solution function matchesPattern pattern if pattern.length 12 return false var i 0 code while i 12 code pattern.charCodeAt i if i 8 i 4 3 if code 48 code 57 return false else if code 45 return false i 1 return true It is available on jsfiddle.. share improve this question even faster than before function tecjam5 pattern var c return pattern.length 12 c pattern.charCodeAt 2 3 6 c 1 28 c pattern.charCodeAt 4 3 6 c 1 28 c pattern.charCodeAt 11 1 28 c 3 6 c pattern.charCodeAt 0 3 6 c 1 28 c pattern.charCodeAt.. even faster than before function tecjam5 pattern var c return pattern.length 12 c pattern.charCodeAt 2 3 6 c 1 28 c pattern.charCodeAt 4 3 6 c 1 28 c pattern.charCodeAt 11 1 28 c 3 6 c pattern.charCodeAt 0 3 6 c 1 28 c pattern.charCodeAt 1 3 6 c 1 28 c pattern.charCodeAt..