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])));
}
}

java 找出字符串之间的字符的更多相关文章

  1. [java] 找出字符串中出现最多的字符和出现的次数

    逛园子看到一童鞋做的华为上机题目,写来好长的代码,懒得看,感觉不可能这么难,于是动手敲了下. import java.util.Scanner; public class StringTest { / ...

  2. 剑指Offer 找出字符串中第一个只出现一次的字符

    题目描述 找出字符串中第一个只出现一次的字符 如果无此字符 请输出'.' 输入描述: 输入一串字符,由小写字母组成 输出描述: 输出一个字符 输入例子: asdfasdfo 输出例子: o 思路:数组 ...

  3. 找出字符串中第一个不重复的字符(JavaScript实现)

    如题~ 此算法仅供参考,小菜基本不懂高深的算法,只能用最朴实的思想去表达. //找出字符串中第一个不重复的字符 // firstUniqueChar("vdctdvc"); --& ...

  4. (1) 一个字符串,根据输入参数m,找出字符串的m个字符的所有字符串

    /** * 有一个字符串,根据输入参数m,找出字符串的m个字符的所有字符串 例如: String str ="abc", m=2 得到结果是 "ab" &quo ...

  5. C/C+面试题一:找出字符串中出现最多的字符和次数,时间复杂度小于O(n^2)

    已知字符串"aabbbcddddeeffffghijklmnopqrst"编程找出出现最多的字符和次数,要求时间复杂度小于O(n^2) /********************* ...

  6. 面试:如何找出字符串的字典序全排列的第N种

    1.题目 如何找出字符串的字典序全排列的第N种?(字符串全排列的变种) 2.思路 主要想通过这题,介绍一下康托展开式.基于康托展开式可以解决这个问题. 一般的解法:①求出所有全排列 ②按照字典序排个序 ...

  7. [LeetCode] Find All Anagrams in a String 找出字符串中所有的变位词

    Given a string s and a non-empty string p, find all the start indices of p's anagrams in s. Strings ...

  8. 【easy】438.Find All Anagrams in a String 找出字符串中所有的变位词

    Input: s: "abab" p: "ab" Output: [0, 1, 2] Explanation: The substring with start ...

  9. [LeetCode] 438. Find All Anagrams in a String 找出字符串中所有的变位词

    Given a string s and a non-empty string p, find all the start indices of p's anagrams in s. Strings ...

随机推荐

  1. iOS 中使用Base64编码方式编码图片数据

    最近一个项目要求对图片数据简单加密下,就是那种不能直接看到图片内容就行.于是我使用了base64编码对图片数据进行编码,把图片2进制数据变成了base64的字符串,再把这个字符串保存到server的数 ...

  2. Java for LeetCode 058 Length of Last Word

    Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the l ...

  3. poj 2013 Symmetric Order 解题报告

    题目链接:http://poj.org/problem?id=2013 设长度非递减的字串序列为s[1]...s[n].设计递归子程序print(n),其中n为字串序号,每分析1个字串,n=n-1. ...

  4. 埃及分数(codevs 1288)

    题目描述 Description 在古埃及,人们使用单位分数的和(形如1/a的, a是自然数)表示一切有理数. 如:2/3=1/2+1/6,但不允许2/3=1/3+1/3,因为加数中有相同的. 对于一 ...

  5. redis的PHP扩展包安装方法

    试用Redis安装.php环境连接.测试  Redis介绍     Redis本质上一个Key/Value数据库,与Memcached类似的NoSQL型数据库,但是他的数据可以持久化的保存在磁盘上,解 ...

  6. php文件上传类

    <?php header("Content-Type:text/html; charset=utf-8"); if($_POST['submit']){ $upfiles = ...

  7. Azure Mobile Services的REST API调用方式和自定义API

    Azure Mobile Services(移动服务)是微软在Azure平台中提供的一种跨平台的移动应用后端服务,即移动后端即服务.支持.NET和JavaScript(Node.js)写后端代码:支持 ...

  8. java写入文件的几种方法分享

    转自:http://www.jb51.net/article/47062.htm 一,FileWritter写入文件 FileWritter, 字符流写入字符到文件.默认情况下,它会使用新的内容取代所 ...

  9. Z-XML团队年终博客整理

    一个优秀的团队一定有逻辑清晰,风格优雅,严格规范的博客. ------图灵 大三上转眼间已经到了收官阶段,我们的软工课也逐渐接近尾声.在二轮迭代即将结束的时候,当我们梳理一路走来的软工课,我们发现自己 ...

  10. onSaveInstanceState和onRestoreInstanceState

    本文摘自: http://h529820165.iteye.com/blog/1399023 Android calls onSaveInstanceState() before the activi ...