asdasd
asdasdasdunknown
c_cpp
3 years ago
792 B
5
Indexable
#include <iostream> #include <string> #include <regex> using namespace::std; int main() { std::string my_str = "0 wzrost<190.0 1 koszykowka %korzen"; std::string b, c,d,e,f; int a; regex regEx("(\\d+)\\s([a-zA-Z]+)([<>])(\\d+[.]\\d+)\\s(\\w+)\\s(\\w+).*"); if (regex_match(my_str, regEx)) { smatch what; regex_search(my_str, what, regEx); a = std::stoi(what[1]); b = what[2]; c = what[3]; d = what[4]; e = what[5]; f = what[6]; } std::cout << "a = " << a << "\n"; std::cout << "b = " << b << "\n"; std::cout << "c = " << c << "\n"; std::cout << "d = " << d << "\n"; std::cout << "e = " << e << "\n"; std::cout << "f = " << f << "\n"; }
Editor is loading...