Its pretty basic, I have some data in the form : (xxxxx)
.
To remove the brackets I do :
long len = strlen(data);
for (int i = 0; i < len - 2; ++i )
data[i] = data[i + 1];
data[len - 2] = '\0';
Which works.
I would like to also take care of another case which is ((xxxxxx))
, and removing the double "(("
at start and end . (and not removing the middle occurrence ) .
Assuming that for every ((
, there is also ))
at the end.
Is there a simple way to modify this code(or another code) to do that with high efficiency ?
EDIT: It is a data parsing, where there are 3 options :
xxxxxx, (xxxxx), ((xxxxx)
Usually I check if the first character is "(" , and apply this function, Now I need that function to also make sure there is not another "(", and if there is , to remove it automatically for me. I can not apply the function twice because If I have only 1 "(" I will loose data.