JAVA-【将字符串中的英文括号替换为中文括号】
生活随笔
收集整理的這篇文章主要介紹了
JAVA-【将字符串中的英文括号替换为中文括号】
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
// 將英文括號(hào)替換成中文括號(hào)private String replaceStr(final String str) {String newNode = null;String allConvertNode = null;// 替換英文括號(hào)的時(shí)候因?yàn)檎齽t表達(dá)式問題,英文前括號(hào)和后括號(hào)的前邊都要加上\\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;}
總結(jié)
以上是生活随笔為你收集整理的JAVA-【将字符串中的英文括号替换为中文括号】的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: compile函数使用
- 下一篇: 区块链就是一场群雄逐鹿的战争