File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Regex Program 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 "Regex Program" Watch "Regex Program" New topic

Regex Program

Srinivas Katta
Ranch Hand

Joined: Feb 01, 2007
Posts: 76

I have executed the below Program from K&B

And the command line:
java Regex2 "\d*" ab34ef

My assumption is that the output would be 0123445 but the actual output displayed is 01234456. I do not understand how?

Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

Check this FAQ.

[My Blog]
All roads lead to JavaRanch
Sahil Kapoor
Ranch Hand

Joined: Sep 12, 2009
Posts: 316
\d* eseentially implies zero or more numeric digits.

Zero length match can occur in several places and one out of it is

After the last character of source data. in your example 6 !!!

See pg 500 in K&B !!!

SCJP 6.0 96%

(Connecting the Dots ....)
I agree. Here's the link:
subject: Regex Program
It's not a secret anymore!