aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes confusion with the Matcher  Class Programs.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "confusion with the Matcher  Class Programs.." Watch "confusion with the Matcher  Class Programs.." New topic
Author

confusion with the Matcher Class Programs..

ishmayel vemuru
Ranch Hand

Joined: Jun 13, 2007
Posts: 46
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
Marshal

Joined: Mar 22, 2005
Posts: 41834
    
  63
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.


Ping & DNS - my free Android networking tools app
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: confusion with the Matcher Class Programs..