O
O
Osklizg2017-04-19 15:58:59
Java
Osklizg, 2017-04-19 15:58:59

How to remove all characters that are outside {}?

Let's say I have a string ab{cde}fg, how to remove the characters that are outside the brackets, what would be {cde}.
Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
romy4, 2017-04-19
@romy4

str.replaceAll(".*(\\{.*?\\}).*","\\1");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question