crawler_编码转换_unicode(年)

 1 import java.util.regex.Matcher;
 2 import java.util.regex.Pattern;
 3 
 4 /**
 5  * @declare: unicode 帮助类<br>
 6  * @author: cphmvp
 7  * @version: 1.0
 8  * @date: 2014年6月10日上午11:45:34
 9  */
10 public class UnicodeUtils {
11     public static void main(String[] args) {
12         String testStr = "2014&#24180;&#26149;&#22799;&#23395;";
13         System.out.println(getStr(testStr));
14     }
15 
16     /**
17      * @declare:得到可见的字符
18      * @param str
19      *            :&#24180;
20      * @return21      * @author cphmvp
22      */
23     public static String getStr(String str) {
24         String regex = "&#(\\w{5});";
25         Pattern pa = Pattern.compile(regex);
26         String str0 = str;
27         Matcher matcher = pa.matcher(str);
28         String tmstr0 = null, tmstr = null, zhuanhuanstr = null;
29         while (matcher.find()) {
30             tmstr0 = matcher.group();
31             tmstr = matcher.group(1);
32             // System.out.println(tmstr);
33             zhuanhuanstr = (char) Integer.parseInt(tmstr) + "";
34             str0 = str0.replace(tmstr0, zhuanhuanstr);
35         }
36         return str0;
37     }
38 
39 }

 

转载于:https://www.cnblogs.com/cphmvp/p/3884723.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值