aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Regex Program 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 Program" Watch "Regex Program" New topic
Author

Regex Program

Srinivas Katta
Ranch Hand

Joined: Feb 01, 2007
Posts: 74
Hi,

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?

Thanks
Srinivas
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14672
    
  11

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: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Regex Program
 
Similar Threads
regex
Matcher.find() -> looks one past end of String?
Greedy quantifiers(*)
Pattern Matching
doubt regarding patterns in regex