Home > Enterprise >  How to remove characters between two specific characters in a String?
How to remove characters between two specific characters in a String?

Time:10-19

How to remove characters between two specific characters in a String?

Example:

Original String: "Hello <>Remove this String<> how are you?"

Modified String: "Hello <><> how are you?"

CodePudding user response:

You can use regex like this:

String result = original.replaceAll("<>.*<>", "<><>");

Output:

Hello <><> how are you?

CodePudding user response:

var result = string.replace('<>.*<>', '<><>')
  • Related