首页 > 编程语言 > 详细

java 找出字符串之间的字符

时间:2015-04-18 14:18:52      阅读:251      评论:0      收藏:0      [点我收藏+]

 

 

技术分享
package lia.meetlucene;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class XMLReaderTest {

    public static List<String> match(String s) {
        List<String> results = new ArrayList<String>();
        Pattern p = Pattern.compile("<text>(.*?)</text>");
        // p = Pattern.compile("<icon>([\\w/\\.]*)</icon>");
        Matcher m = p.matcher(s);
        while (!m.hitEnd() && m.find()) {
            results.add(m.group(1));
        }
        return results;
    }

    public static void main(String[] args) throws IOException {
        String s = "<text>能找到前方红绿灯在何处吗 堵车堵的这个神奇啊</text><timestamp>1406595562</timestamp>";
        System.out.println(Arrays.toString(Unicode1.match(s).toArray(
                new String[0])));
    }
}
View Code

 

java 找出字符串之间的字符

原文:http://www.cnblogs.com/XDJjy/p/4437212.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!