#include <iostream>
#include <string>
#include <regex>
using namespace std;
int main() {
string str = "d0jugh9rdhgh489e0yre32u41-2ik1k210=3u230nfrui yu31y243uj29i`1-";
smatch sm;
const regex re(R"(\d+)");
string a, b;
while (regex_search(str, sm, re)) {
a += sm.str();
b += sm.str() + ' ';
str = sm.suffix();
}
b.erase(b.back());
cout << a << '\n' << b;
cin.get();
}
P.S. Строка «a» – без пробелов, строка «b» – через пробел.