Remove characters from a String (or generate a new one without them) that are between two special characters

Asked

Viewed 25 times

0

I need some help in this case, I have a string and I would need to remove some characters from it.

String minhaStr = "{"abcde{"fg":"hij"}"

I need to remove everything between the keys {, ie in this case would be "abcde:

String minhaNovaStr = "{{"fg":"hij"}"

I would not like to use substring or something like that because I actually have a list of strings that would need to apply this logic, and they don’t follow the same pattern of number of characters for example. The only pattern they follow is that they are between two keys {. I gave a search on Stringbuilder but so far in my research I haven’t found anything specific that can help me, someone would kindly idea?

  • 2

    It’s not exactly the same, but it can help: https://answall.com/q/393375/112052 - by taking advantage, these strings are wrong and this code does not compile, because of the various quotes...

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.