How to make HTML5 email validation regex work in C++?

前端 未结 2 1020
别跟我提以往
别跟我提以往 2021-01-23 09:25

I am trying to validate email both on the client-side and on the server-side. The client-side is JavaScript(web front-end). The server-side is written in C++11.

The rege

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-23 10:00

    The regex you are running is expecting a / before the start (^) and after the end ($) of the string. You need to remove the /^ and $/ at the beginning and end:

    "([a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)"
    

提交回复
热议问题