Advertisement
apuntesdejava

RegTest0

Feb 4th, 2015
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.52 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement