• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

confusion with the Matcher Class Programs..

 
ishmayel vemuru
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import java.util.regex.*;
class Regex2
{
public static void main(String[] args)
{
Pattern p = Pattern.compile(args[0]); // "\d*"
Matcher m = p.matcher(args[1]); //ab34ef
boolean b = false;
while(b = m.find())
{
System.out.print(m.start() + m.group());
}
}
}
Run this above prgam with java Regex2 "\d*" ab34ef
Can any one explain this above program please...Preparing for SCJP 5.0..
Thanks in advance..
Ishmayel.
[ November 27, 2007: Message edited by: ishmayel vemuru ]
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You didn't say what you're confused about, but this particular example is asked about so often that it has its own FAQ entry.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic