aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Regex Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Regex" Watch "Regex" New topic
Author

Regex

Natasha Basu
Greenhorn

Joined: Nov 21, 2008
Posts: 10
This is a question from the certification book by Kathy Sierra Chapter 6

import java.util.regex.*
class Regex2{
public static void main (String[] args){
Pattern p=Pattern.matcher(args[0]);
Matcher m=p.matcher(args[1]);
boolean b=false;
while(b=m.find()){
System.out.println(m.start() + m.group());
}
}
}
And the command line:
java Regex2 "\d*" ab34ef

and the answer is 01234456

I would like to know how that answer was arrived at?

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35252
    
    7
That's a FAQ: http://faq.javaranch.com/java/ScjpFaq#kb-regexp


Android appsImageJ pluginsJava web charts
Natasha Basu
Greenhorn

Joined: Nov 21, 2008
Posts: 10
Thank you. I could not understand the digit 6 in the end. Thank you again
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regex
 
Similar Threads
Doubt about K&B Chapter 6 Question 1
Chapter 6 Self Test Q1
Java command-line input argument??
SCJP question doubt?
Regex doubt