@ohadlevy, I updated the code to use the result of .match() rather than the global variable $1 for the first regex match.