/**
*
* @author Jasmine
*/
public class TestPattern
{
public static void main(String[] args)
{
String patternString;
Pattern pattern ;
Matcher matcher;
String output;
patternString = "INTERVAL\\([0-9]\\)";
pattern = Pattern.compile(patternString,Pattern.CASE_INSENSITIVE);
matcher = pattern.matcher("INTERVAL(4)");
System.out.println(matcher.matches());
patternString = "INTERVAL DAY\\(\\d{1,9}\\) TO SECOND\\([0-9]\\)";
pattern = Pattern.compile(patternString,Pattern.CASE_INSENSITIVE);
matcher = pattern.matcher("INTERVAL DAY(123456789) TO SECOND(6)");
System.out.println(matcher.matches());
output = matcher.replaceAll("INTERVAL(6)");
System.out.println(output);
patternString = "INTERVAL YEAR\\(\\d{1,9}\\) TO MONTH";
pattern = Pattern.compile(patternString,Pattern.CASE_INSENSITIVE);
String s1 = "INTERVAL YEAR(4) TO MONTH";
matcher = pattern.matcher(s1);
System.out.println(matcher.matches());
output = matcher.replaceAll("INTERVAL");
System.out.println(output);
}
}