How to program the search for the first word in a string using a regular C ++ expression? A lot of revised information, but there is nothing sensible. The regular expression itself was written, but I don’t know how to make the search ...
1 answer
Hmm .. I came up with this way:
#include <iostream> #include <string> #include <regex> using namespace std; int main() { string str = "Just a string :)"; string res = regex_replace(str, regex("^\\W*(\\w+).*$"), "$1"); cout << res << endl; return 0; } And how to find exactly the entries, something is not googled: (
|
"Just a string :)".match(/\w+/)[0]- Qwertiy ♦