File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

confusion with the Matcher Class Programs..

 
ishmayel vemuru
Ranch Hand
Posts: 46
  • 0
  • 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
Pie
Posts: 42966
73
  • 0
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic