Beware /g on regexps in JS
Successive matches may fail if the same string is used.
See http://jsbin.com/ixoqan/1/edit for an example.
Written by Ben Lowery
Related protips
1 Response
Interesting, the full explanation is in here:
http://stackoverflow.com/questions/2630418/javascript-regex-returning-true-then-false-then-true-etc
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Regexp
Authors
Did you know?
JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.
Security insights from Cside
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#