C++ search "regex operators" with regex -


im using regex in c++ , want regex_search * , + symbols, wont work, cause regex symbols. (using namespace std)

string s = "15 * 12"; regex rx("*"); bool flag = regex_search(s, rx); 

and

terminating uncaught exception of type std::__1::regex_error: 1 of *?+{ not preceded valid regular expression. 

how can fix that?

you need escape special characters using '\'. if specify in c++ string constant need add 2 '\' "\*".


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -