fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.util.regex.*;
  5. import java.lang.*;
  6. import java.io.*;
  7.  
  8. /* Name of the class has to be "Main" only if the class is public. */
  9. class Ideone
  10. {
  11. public static void main (String[] args) throws java.lang.Exception
  12. {
  13. // your code goes here
  14. String p1 = "column1 = emp_no";
  15.  
  16. String propertyRegexp = "^\\s*(\\w+)\\s*=\\s*(\\w+)\\s*$";
  17.  
  18. Pattern pattern = Pattern.compile(propertyRegexp);
  19. Matcher matcher = pattern.matcher(p1);
  20. System.out.println("groupCount: " + matcher.groupCount());
  21. if(matcher.matches()) {
  22. for(int i = 1; i <= matcher.groupCount(); i++) { //see the changes
  23. System.out.println(i + ": " + matcher.group(i));
  24. }
  25. }
  26. }
  27. }
Success #stdin #stdout 0.11s 320576KB
stdin
Standard input is empty
stdout
groupCount: 2
1: column1
2: emp_no