HTMLForm: Avoid usage of non-standard 'flags' parameter of String#replace

Chrome (and most other browser) don't support the non-standard 'flags'
argument to String#replace (implemented by Mozilla Firefox). Instead pass
a RegExp object with those flags.

Bug: 68050
Change-Id: Ia463002e708975eed1a5c3657f2e1a4d6b4e74de