How to remove entire substring from '<' to '>' in Java

前端 未结 2 1739
北恋
北恋 2021-02-04 14:14

I have a program that takes an input string. I want to delete anything inside the characters \'<\' and \'>\'. For example if the string says

\"P.S. Hello how are you today?";
String revised = origText.substring(0, origText.indexOf('<')) +
    origText.substring(origText.lastIndexOf('>')+1, origText.length());

`Java String Class Reference

提交回复
热议问题