正则表达式使用语句
2011-08-31 21:13
162 查看
package corejava.ioutils;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
//行动力
public class RegexTestHarnessV5 {
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("Found \"%s\" starting index %d ending index %d.%n",
matcher.group(), matcher.start(), matcher.end());
found = true;
}
if (!found) {
System.out.printf("No match found.%n");
}
}
}
}
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
//行动力
public class RegexTestHarnessV5 {
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("Found \"%s\" starting index %d ending index %d.%n",
matcher.group(), matcher.start(), matcher.end());
found = true;
}
if (!found) {
System.out.printf("No match found.%n");
}
}
}
}
相关文章推荐
- 如何在SQL语句中使用正则表达式
- SQL语句--like和正则表达式的使用
- 使用正则表达式检验sql语句(只支持select(不含函数,子
- 在Sql语句中使用正则表达式来查找你所要的字符
- 在SQL语句中使用正则表达式
- sql语句中使用正则表达式
- 在Sql语句中使用正则表达式来查找你所要的字符
- 在Sql语句中使用正则表达式来查找你所要的字符 及调试问题
- 使用UE 正则表达式 查找siebel log文件 sql耗时较长的语句
- java语句中使用正则表达式
- 使用正则表达式解析语句
- 使用正则表达式匹配tsql注释语句
- 使用正则表达式获取Sql查询语句各项(表名、字段、条件、排序)
- 使用正则表达式匹配tsql注释语句
- 如何使用JavaScript和正则表达式进行数据验证
- C#正则表达式的使用(Regex类用法)
- 如何在Delphi中使用正则表达式
- php中使用正则表达式的方法
- 使用正则表达式提取内容串中的图片连接
- oracle plsql中使用正则表达式。