They are both matching methods but the difference mainly lies on the result you want and the performance. First, test() returns true/false to if a match is found, on the other hand, match() returns the matching string. Secondly, test() has a better performance. Use them wisely.
Reference links
http://stackoverflow.com/questions/10940137/regex-test-v-s-string-match-to-know-if-a-string-matches-a-regular-expression
沒有留言:
張貼留言