Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Get early access and see previews of new features.
How to remove characters between two specific characters in a String?
Example:
Original String: "Hello <>Remove this String<> how are you?"
"Hello <>Remove this String<> how are you?"
Modified String: "Hello <><> how are you?"
"Hello <><> how are you?"
"aaaa<>bbbbb<>ccccc<>dddd"
You can use regex like this:
String result = original.replaceAll("<>.*<>", "<><>");
Output:
Hello <><> how are you?
"<>.*<>"
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.
Your privacy
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.
"aaaa<>bbbbb<>ccccc<>dddd"
.