wood burning stoves 2.0
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes simple regex 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 "simple regex" Watch "simple regex" New topic

simple regex

ahmed yehia
Ranch Hand

Joined: Apr 22, 2006
Posts: 424
I have the below code runs fine but I dont get the output.


why would it print "2" at the end after group.
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

Because you are using "*", which means zero or more times. So after finding "33", it also finds a non matching empty string, at index 2.
It would work as expected if you'd use "+" instead.

[My Blog]
All roads lead to JavaRanch
I agree. Here's the link: http://aspose.com/file-tools
subject: simple regex
It's not a secret anymore!