I want to add the closing parenthesis where the string starts with [[
I tried using find_if, replace_if but it turns out that something isn't right
std::vector<std::string> vector(3);
contains:
0: text
1: [[text
2: text
What I want:
0: text
1: [[text]]
2: text
Could you help with algorithm explanation?
Maybe something like this:
for (std::string & s : vector)
{
if (s.size() > 1 && s[0] == '[' && s[1] == '[')
s += "]]";
}
If you want to check for already existing brackets, add some more checks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With