aspose file tools*
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
Author

simple regex

ahmed yehia
Ranch Hand

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


output:
0332

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

Joined: Nov 24, 2005
Posts: 14687
    
  16

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
 
Similar Threads
Try this homemade question of mine !
Overriding of Member variables
what will be the output?
Cannot Open Excel file in Browser. + JSF + JSP + Bean