JAVA-【将字符串中的英文括号替换为中文括号】
生活随笔
收集整理的這篇文章主要介紹了
JAVA-【将字符串中的英文括号替换为中文括号】
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
// 將英文括號替換成中文括號private String replaceStr(final String str) {String newNode = null;String allConvertNode = null;// 替換英文括號的時候因為正則表達式問題,英文前括號和后括號的前邊都要加上\\if (str.contains("(") && str.contains(")")) {newNode = str.replaceAll("\\(", "(");allConvertNode = newNode.replaceAll("\\)", ")");} else if (str.contains("(") && !str.contains(")")) {allConvertNode = str.replaceAll("\\(", "(");} else if (!str.contains("(") && str.contains(")")) {allConvertNode = str.replaceAll("\\)", ")");} else {allConvertNode = str;}return allConvertNode;}
總結
以上是生活随笔為你收集整理的JAVA-【将字符串中的英文括号替换为中文括号】的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: compile函数使用
- 下一篇: 区块链就是一场群雄逐鹿的战争