1 package rero.util; 2 3 import java.util.regex.*; 4 5 public class StringParser 6 { 7 Pattern myPattern; 8 Matcher myMatcher; 9 10 public StringParser( String matchMe, Pattern aPattern ) 11 { 12 myPattern = aPattern; 13 myMatcher = aPattern.matcher(matchMe); 14 } 15 16 public String getParsedString(int index) 17 { 18 return myMatcher.group(index + 1); 19 } 20 21 public String [] getParsedStrings() 22 { 23 String [] returnValue = new String [myMatcher.groupCount()]; 24 for (int x = 0; x < returnValue.length; x++) 25 { 26 returnValue[x] = myMatcher.group(x + 1); 27 } 28 return returnValue; 29 } 30 31 public boolean matches() 32 { 33 return myMatcher.matches(); 34 } 35 } 36 | Popular Tags |