首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Eclipse开发 >

Eclipse 登记类

2013-12-23 
Eclipse 注册类import java.util.Scannerimport java.util.regex.Matcherimport java.util.regex.Patter

Eclipse 注册类

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

?

热点排行