String 字符串去除特殊字符和空格,正则表达式使用,%1$s
生活随笔
收集整理的這篇文章主要介紹了
String 字符串去除特殊字符和空格,正则表达式使用,%1$s
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
特殊字符
String tt = "sdfdf{fwe }fwef< fwef #$";String regEx="[`~!@#$%^&*()+=|{}':;'\\[\\].<>/?~!@#¥%……&*()——+|{}【】';:”“’。、?]"; Pattern p = Pattern.compile(regEx); Matcher m = p.matcher(tt); String toSpeechText=m.replaceAll("").trim(); Log.i("lgq","ww正則==="+toSpeechText);Pattern pattern = Pattern.compile("\t|\r|\n|\\s*"); Matcher matcher = pattern.matcher(toSpeechText); String dest = matcher.replaceAll("");Log.i("lgq","ww正則222==="+dest);?
04-29 08:58:47.569 14311-14311/com.dlc.mytestttt I/lgq: ww正則===sdfdffwe fwef fwef
04-29 08:58:47.569 14311-14311/com.dlc.mytestttt I/lgq: ww正則222===sdfdffwefweffwef
?
Android String標(biāo)簽使用,實(shí)現(xiàn)組合字符串
?
<string name="total_price"><![CDATA[ <font color="#666666">共%1$d件商品 小計(jì):</font><font color="#FB6D74">¥%2$s</font> ]]></string>調(diào)用
mTvTotalPrice.setText(Html.fromHtml(getString(R.string.total_price, mGoodsInfo.getBuyNum(), mGoodsInfo.getTotalPrice())));?
s代表String類型d代表數(shù)字類型
<string name="kedikou">可抵扣%1$s元</string>調(diào)用
mTvDeduction.setText(getString(R.string.kedikou, dikouMoney));#8195是空格
<string name="pick_up_store">提貨門店:%1$s %2$s</string>調(diào)用
textView.setText(getString(R.string.pick_up_store, "第一", "第二二"));?
總結(jié)
以上是生活随笔為你收集整理的String 字符串去除特殊字符和空格,正则表达式使用,%1$s的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 极域电子教室加密狗怎么激活
- 下一篇: 理解文档对象模型(3)