List of usage examples for java.util.regex Pattern compile
public static Pattern compile(String regex)
From source file:MainClass.java
public static void main(String[] args) { Pattern patt = Pattern.compile("(\\w+)\\s(\\d+)"); Matcher matcher = patt.matcher("Bananas 123"); matcher.lookingAt();/*from w w w. jav a 2 s . c o m*/ System.out.println("Name: " + matcher.group(1)); System.out.println("Number: " + matcher.group(2)); }
From source file:Main.java
public static void main(String args[]) { Pattern p = Pattern.compile(" "); String tmp = "this is a test"; String[] tokens = p.split(tmp); for (int i = 0; i < tokens.length; i++) { System.out.println(tokens[i]); }// w w w .j a v a 2 s . c om }
From source file:Main.java
public static void main(String[] args) { String str = "XML,CSS,HTML"; Pattern.compile(",").splitAsStream(str).forEach(System.out::println); }
From source file:PatternSplitExample.java
public static void main(String args[]) { Pattern p = Pattern.compile(" "); String tmp = "this is the String I want to split up"; String[] tokens = p.split(tmp); for (int i = 0; i < tokens.length; i++) { System.out.println(tokens[i]); }//from www .java 2 s . c o m }
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: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: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:RegExpr7.java
public static void main(String args[]) { Pattern pat = Pattern.compile("[a-z]+"); Matcher mat = pat.matcher("this is a test."); while (mat.find()) System.out.println("Match: " + mat.group()); }
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: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()); }