Java Regex模式匹配示例


Java Regex模式匹配示例

package com.codingdict;



import java.util.regex.Matcher;

import java.util.regex.Pattern;



public class PatternDemo {



   private static final String REGEX = "foo*";

   private static final String INPUT = "fooooooooooooooooo";



   public static void main( String args[] ) {



      System.out.println("Current REGEX is: "+REGEX);

      System.out.println("Current INPUT is: "+INPUT);



      System.out.println("matches(): "+Pattern.matches(REGEX,INPUT));

   }

}