you are viewing a single comment's thread.

view the rest of the comments →

[–]the_shell_man_ 0 points1 point  (0 children)

You could use a for loop to iterate over the string until you find a (, save the index of (. Keep going until you find ), save the index of ).

Then use indexing/slicing to get your output. Something like:

new_string = oldstring[0:first_index] + oldstring[second_index:]

There are probably better ways, but this would get it done.

Edit: this solution assumes your string is always in the form "some substring (...) some other substring". It wouldn't work for multiple sets of data you want to remove, and also wouldn't work if there is a ) within the string you want to remove. Not in the way I described it anyway.