没有合适的资源?快使用搜索试试~ 我知道了~
wap代码 html过滤器(java)

温馨提示
wap代码 html过滤器(用java写的)
资源推荐
资源详情
资源评论
























//--新增wap代码
//过滤器
public static String filter(String str)
{
String s1 = str;
s1 = s1.replaceAll("(</p>)|</P>","<br>");
s1 = s1.replaceAll("(</div>)|</DIV>","<br>");
try
{
//Pattern pattern=Pattern.compile("<[^<|^>]*>");
Pattern pattern=Pattern.compile("(<[^<|^>]*>)|(\\{[^\\{|^\\}]*\\})",Pattern.CASE_INSENSITIVE);
Matcher matcher=pattern.matcher(s1);
StringBuffer txt=new StringBuffer();
while(matcher.find())
{
String group=matcher.group();
if(group.matches("<[ \\s]*>"))
{
matcher.appendReplacement(txt,group);
}
else
{
if(group.matches("<(IMG|img) [^<|^>]*>")) //判断是img标签
{
if(group.indexOf("_wap")==-1){//2008-8-19
group = group.substring(0,group.lastIndexOf("."))+"_wap"+group.substring(group.lastIndexOf("."),group.length()).toLowerCase();
}
if(group.indexOf("bmp")!=-1){
group=group.replaceAll("_wap","");
}
//过滤器
public static String filter(String str)
{
String s1 = str;
s1 = s1.replaceAll("(</p>)|</P>","<br>");
s1 = s1.replaceAll("(</div>)|</DIV>","<br>");
try
{
//Pattern pattern=Pattern.compile("<[^<|^>]*>");
Pattern pattern=Pattern.compile("(<[^<|^>]*>)|(\\{[^\\{|^\\}]*\\})",Pattern.CASE_INSENSITIVE);
Matcher matcher=pattern.matcher(s1);
StringBuffer txt=new StringBuffer();
while(matcher.find())
{
String group=matcher.group();
if(group.matches("<[ \\s]*>"))
{
matcher.appendReplacement(txt,group);
}
else
{
if(group.matches("<(IMG|img) [^<|^>]*>")) //判断是img标签
{
if(group.indexOf("_wap")==-1){//2008-8-19
group = group.substring(0,group.lastIndexOf("."))+"_wap"+group.substring(group.lastIndexOf("."),group.length()).toLowerCase();
}
if(group.indexOf("bmp")!=-1){
group=group.replaceAll("_wap","");
}
资源评论

- hansheng98222014-07-28现在可能没人用这个代码了吧,我也是很久前用的,现在才来评论,我承认我是来混积分的,不过这个代码当时确实帮助了我,解决了实际问题,还是要感谢一下

21世纪如来神掌
- 粉丝: 9
- 资源: 18
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


会员权益专享
安全验证
文档复制为VIP权益,开通VIP直接复制
