java 找出字符串之间的字符
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 找出字符串之间的字符的更多相关文章
- [java] 找出字符串中出现最多的字符和出现的次数
逛园子看到一童鞋做的华为上机题目,写来好长的代码,懒得看,感觉不可能这么难,于是动手敲了下. import java.util.Scanner; public class StringTest { / ...
- 剑指Offer 找出字符串中第一个只出现一次的字符
题目描述 找出字符串中第一个只出现一次的字符 如果无此字符 请输出'.' 输入描述: 输入一串字符,由小写字母组成 输出描述: 输出一个字符 输入例子: asdfasdfo 输出例子: o 思路:数组 ...
- 找出字符串中第一个不重复的字符(JavaScript实现)
如题~ 此算法仅供参考,小菜基本不懂高深的算法,只能用最朴实的思想去表达. //找出字符串中第一个不重复的字符 // firstUniqueChar("vdctdvc"); --& ...
- (1) 一个字符串,根据输入参数m,找出字符串的m个字符的所有字符串
/** * 有一个字符串,根据输入参数m,找出字符串的m个字符的所有字符串 例如: String str ="abc", m=2 得到结果是 "ab" &quo ...
- C/C+面试题一:找出字符串中出现最多的字符和次数,时间复杂度小于O(n^2)
已知字符串"aabbbcddddeeffffghijklmnopqrst"编程找出出现最多的字符和次数,要求时间复杂度小于O(n^2) /********************* ...
- 面试:如何找出字符串的字典序全排列的第N种
1.题目 如何找出字符串的字典序全排列的第N种?(字符串全排列的变种) 2.思路 主要想通过这题,介绍一下康托展开式.基于康托展开式可以解决这个问题. 一般的解法:①求出所有全排列 ②按照字典序排个序 ...
- [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 ...
- 【easy】438.Find All Anagrams in a String 找出字符串中所有的变位词
Input: s: "abab" p: "ab" Output: [0, 1, 2] Explanation: The substring with start ...
- [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 ...
随机推荐
- 【python】lxml查找属性为指定值的节点
假设有如下xml在/home/abc.xml位置 <A> <B id=" name="apple"/> <B id=" name= ...
- UVALive 7267 Mysterious Antiques in Sackler Museum (判断长方形)
Sackler Museum of Art and Archaeology at Peking University is located on a beautiful site near the W ...
- NEFU 2016省赛演练一 B题(递推)
HK Problem:B Time Limit:2000ms Memory Limit:65535K Description yy is interested in numbers and yy nu ...
- 数码管的封装实验 --- verilog
数码管的封装实验.显示使能信号置高才可以显示.对于小数点不用,故不显示. 数码管分为共阴数码管和共阳数码管,数码管不同,编码不同,下面是两种数码管显示0-F以及消隐的不同编码: 共阴数码管(高有效): ...
- gitlab安装
[root@localhost ~]# wget https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rp ...
- SQL中行列转换Pivot
--建表 ),课程 ),分数 int) --插入数据 ) ) ) ) ) ) 1.静态行转列(确定有哪些列) select 姓名, end)语文, end)数学, end)物理 from tb gro ...
- CI中PHP写法规范(不断更新)
1.类名首字母大写,多个单词用下划线连接,首字母小写是无效的 举例: class CI_Model 2.routes路由配置中的右侧在配置类名和方法名的时候都是小写,如果大写可能会出现404找不到的错 ...
- .net学习之新语法学习(匿名类和匿名方法,扩展方法,系统内置委托,Lambda表达式和linq等)
1.自动属性 Auto-Implemented Properties 2.隐式类型 var var变量不能作为全局变量使用,因为不能在编译时确定类型 3.参数默认值 和 命名参数 4.对象初始化器 ...
- 利用JS提交表单的几种方法和验证
第一种方式:表单提交,在form标签中增加onsubmit事件来判断表单提交是否成功 <script type="text/javascript"> function ...
- Java反编译利器-Jad, Jode, Java Decompiler等及其IDE插件
转自:http://blog.csdn.net/superbeck/article/details/5189231 对于长年使用Java的程序员,大部分应该都会或多或少的使用到反编译软件.毕竟,不可能 ...