Regex on Chrome pattern input validation

前端 未结 1 1190
清歌不尽
清歌不尽 2021-01-25 10:21

I have an RFC 5322 compliant email regex pattern to validate my input. This works in all browsers, but Chrome show me the following error on console:

Pattern att         


        
相关标签:
1条回答
  • 2021-01-25 10:37

    Since Chrome pattern attribute automatically adds u modifier, stricter rules for regex syntax are applied. Basically, you cannot escape arbitrary symbols. If the symbol is not a special regex metacharacter, you cannot escape it, or you will get this error.

    So, in your case, the single apostrophe must not be escaped. Remove the escaping backslash before it, and the regex will work in every browser again.

    0 讨论(0)
提交回复
热议问题