Add global flag for regex to match correct pattern.