Reputation: 1165
I am using regex to format my input string, my problem is that my string has to replace too many different values so that I have to use many regexes.
My question is, can I redefine a regex to save the system memory?
std::regex y_re("y+");
y_re("a+"); // can I do this, it shows error but is there a way to reuse regex?
Upvotes: 0
Views: 155
Reputation: 91
Try redefining in this way:
std::regex y_re("y+");
y_re = std::regex("a+");
The memory should be reused.
Upvotes: 1