List of usage examples for java.util.regex Pattern matcher
public Matcher matcher(CharSequence input)
From source file:Main.java
License:asdf
public static void main(String[] args) { Pattern p = Pattern.compile("\\d+"); Matcher m = p.matcher("(345+3)*/3asdf234234234/234234234/23asdfaasd1f2a3s4d54fadsf"); while (m.find()) System.out.println(m.group()); }
From source file:MainClass.java
public static void main(String args[]) { Pattern p = Pattern.compile("\\d"); Matcher m1 = p.matcher("55"); Matcher m2 = p.matcher("fdshfdgdfh"); System.out.println(m1.pattern() == m2.pattern()); }
From source file:RegExpr4.java
public static void main(String args[]) { Pattern pat = Pattern.compile("W+"); Matcher mat = pat.matcher("W WW WWW"); while (mat.find()) System.out.println("Match: " + mat.group()); }
From source file:Main.java
public static void main(String[] args) { String s = "stuff1 (foo1(bar1)foo2) stuff2 (bar2) stuff3"; String re = "\\([^()]*\\)"; Pattern p = Pattern.compile(re); Matcher m = p.matcher(s); while (m.find()) { s = m.replaceAll(""); m = p.matcher(s);//from ww w. j ava 2 s. c om } System.out.println(s); }
From source file:Main.java
public static void main(String args[]) { Pattern p = Pattern.compile("\\d"); Matcher m1 = p.matcher("55"); Matcher m2 = p.matcher("fdshfdgdfh"); System.out.println(m1.pattern() == m2.pattern()); // return true }
From source file:Main.java
public static void main(String args[]) { Pattern p = Pattern.compile("test"); Matcher matcher = p.matcher("this is a test"); // display the output for the candidate System.out.println(matcher.lookingAt()); }
From source file:RegExpr5.java
public static void main(String args[]) { Pattern pat = Pattern.compile("e.+d"); Matcher mat = pat.matcher("extend cup end table"); while (mat.find()) System.out.println("Match: " + mat.group()); }
From source file:Main.java
public static void main(String[] args) { Pattern p = Pattern.compile(REGEX); Matcher m = p.matcher(INPUT); // get a matcher object while (m.find()) { System.out.println("start(): " + m.start()); System.out.println("end(): " + m.end()); }//from w ww.j a va 2s .c o m }
From source file:RegExpr6.java
public static void main(String args[]) { Pattern pat = Pattern.compile("e.+?d"); Matcher mat = pat.matcher("extend cup end table"); while (mat.find()) System.out.println("Match: " + mat.group()); }
From source file:RegExpr3.java
public static void main(String args[]) { Pattern pat = Pattern.compile("test"); Matcher mat = pat.matcher("test 1 2 3 test"); while (mat.find()) { System.out.println("test found at index " + mat.start()); }// w w w . ja v a 2s. c o m }