SHARE
TWEET

RegTest0

apuntesdejava Feb 4th, 2015 166 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.regex.*;
  2. class RegTest1{
  3.         public static void main(String[] args){
  4.                 String expression=args[0],
  5.                        source=args[1];
  6.                 Pattern p=Pattern.compile(expression);
  7.                 Matcher m=p.matcher(source);
  8.                
  9.                 System.out.println("expression:" +m.pattern());
  10.                 System.out.println("source:" +expression);
  11.                 System.out.println(" index:012345678901234567890" );
  12.                 System.out.println("       0         1         2\n" );
  13.                 System.out.println("match positions:");
  14.                 while(m.find())
  15.                         System.out.print(m.start()+" ");
  16.         }
  17. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top