如何删除不需要的字符串中的字符 [英] How to remove unwanted characters in a string

查看:185
本文介绍了如何删除不需要的字符串中的字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我从服务器获取JSON响应。我解析它。但是从响应字符串看起来像这样

hi I am getting a json response from the server. I parsed it . but the String from the response looked like this

&roominfo LT; BR />< BR /> < P><强>声明:< / STRONG>< BR />< / P>< P>< UL><李>一种度假费已包含在总价&LT ; /李> &所述; / UL>&下; / P>&所述p为H.;&下; / P>&所述p为H.;&下; / P> < P>在以下费用和押金由酒店在提供服务时收取,办理入住或退房手续。 < UL><李>代客停车费用:每晚USD30(中/自由进出)LT; /李><李>宠物费:45美元每次住宿< /李><李>无线上网费用所有公共区域:USD 11.95(包24小时,费率可能会发生变化)< /李><李>费用室内无线上网费用:11.95(包24小时,费率可能会发生变化)< /李> &所述; / UL>&下; / P>&所述; P>将上面所列可能并不玉米prehensive。这些费用和押金可能不包括税款,并且有可能发生变化。 < / P>

roominfo<br /><br /> <p><strong>Notifications and Fees:</strong><br /></p><p><ul><li>A resort fee is included in the total price displayed</li> </ul></p><p></p><p></p> <p>The following fees and deposits are charged by the property at time of service, check-in, or check-out. <ul><li>Valet parking fee: USD 30 per night (in/out privileges)</li><li>Pet fee: USD 45 per stay</li><li>Fee for wireless Internet in all public areas: USD 11.95 (for 24 hours, rates may vary)</li><li>Fee for in-room wireless Internet: USD 11.95 (for 24 hours, rates may vary)</li> </ul></p><p>The above list may not be comprehensive. Fees and deposits may not include tax and are subject to change. </p>

如何从这个字符串删除不需要的字符

how to remove the unwanted characters from this string

推荐答案

如果您不需要的角色是 HTML 标签然后用这个

If your unwanted character are HTML tags then use this

 String noHTMLString = htmlString.replaceAll("\\<.*?>","");

它使用一个普通的前pression来移除封闭括号的任何文字。

It uses a regular expression to remove any text that is enclosed with brackets.

这篇关于如何删除不需要的字符串中的字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆