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

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..
[ November 27, 2007: Message edited by: ishmayel vemuru ]
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 41104
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
I agree. Here's the link: http://aspose.com/file-tools
subject: confusion with the Matcher Class Programs..
Similar Threads
Pattern Class Doubt
Doubt about Regular Expression
Greedy quantifiers(*)
Regarding regex
Java command-line input argument??