How can I get inside parentheses value in a string?

前端 未结 10 741
半阙折子戏
半阙折子戏 2020-12-23 13:35

How can I get inside parentheses value in a string?

String str= "United Arab Emirates Dirham (AED)";

I need only AED text.

10条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-23 14:16

    You could try:

    String str = "United Arab Emirates Dirham (AED)";
    int firstBracket = str.indexOf('(');
    String contentOfBrackets = str.substring(firstBracket + 1, str.indexOf(')', firstBracket));
    

提交回复
热议问题