Issue with regular expressions in C++

前端 未结 3 347
死守一世寂寞
死守一世寂寞 2021-01-27 13:03

I tried to use the following regular expression, which already works in C#, in C++ as well but it\'s not working in C++.

         


        
3条回答
  •  粉色の甜心
    2021-01-27 13:46

    A simple regular expression that works with VC++ and fits your description would be

      std::regex("^([^%]|%(\\.[0-9]+)?[a-zA-Z])*$", std::regex::extended)
    

    Live demo

    (Change [0-9]+ to [0-9]* if digits after %. should be optional).

提交回复
热议问题