std::regex, to match begin/end of string

前端 未结 4 1338
误落风尘
误落风尘 2020-12-31 05:46

In JS regular expressions symbols ^ and $ designate start and end of the string. And only with /m modifier (multiline

4条回答
  •  隐瞒了意图╮
    2020-12-31 06:22

    The following code snippet matches email addresses starting [a-z] followed by 0 or 1 dot, then by 0 or more a-z letters, then ending with "@gmail.com". I tested it.

    string reg = "^[a-z]+\\.*[a-z]*@gmail\\.com$";
    
    regex reg1(reg, regex_constants::icase);
    reg1(regex_str, regex_constants::icase);
    string email;
    cin>>email;
    if (regex_search(email, reg1))
    

提交回复
热议问题