正则表达式
来源:互联网 发布:flash编程教程 编辑:程序博客网 时间:2024/05/20 16:11
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RegexTest {
/**
* @param args
*/
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while (true) {
System.out.printf("%nEnter your regex: ");
Pattern pattern = Pattern.compile(scanner.nextLine());
System.out.printf("Enter input string to search: ");
Matcher matcher = pattern.matcher(scanner.nextLine());
boolean found = false;
while (matcher.find()) {
System.out.printf(
"I found the text \"%s\" starting at index %d and ending at index %d.%n",
matcher.group(), matcher.start(), matcher.end()
);
found = true;
}
if (!found) {
System.out.printf("No match found.%n");
}
}
}
}
- 【正则表达式】正则表达式
- 正则表达式
- 正则表达式
- 正则表达式
- 正则表达式
- 正则表达式
- 正则表达式
- 正则表达式
- 正则表达式
- 正则表达式
- 正则表达式
- 正则表达式
- 正则表达式
- 正则表达式
- 正则表达式
- 正则表达式
- 正则表达式
- 正则表达式
- UVALive - 2326 Moving Tables
- ubuntu start
- Android JNI开发入门之一
- 实现求出若干整数之和为500的连续整数(如98,99,100,101,102)的所有组合&&产生一个int数组,长度为100,并向其中随机插入1~100,要求不能重复
- Struts是如何实现MVC的
- 正则表达式
- 一步步学算法(算法题解)---1
- c++多态性与虚函数(二)
- 2011-10-9百度技术,软件研发笔试题(90%)
- 菜鸟应用发布 全民跨入APP2.0时代
- 【转载】软链接
- android 中使用layoutflat实例化xml文件
- 使用AppWidget跳转Activity
- hdu 2846 经典字典树