zoukankan      html  css  js  c++  java
  • 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 }
  • 相关阅读:
    LeetCode 72. Edit Distance
    LeetCode 71. Simplify Path
    LeetCode 70. Climbing Stairs
    LeetCode 69. Sqrt(x)
    Ubuntu系统测评
    itchat 爬了爬自己的微信通讯录
    logistic回归模型
    多元线性回归模型
    可乐鸡翅制作难点
    梯度下降算法&线性回归算法
  • 原文地址:https://www.cnblogs.com/cphmvp/p/3884723.html
Copyright © 2011-2022 走看看