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

pattern matching

vineet walia
Ranch Hand

Joined: Feb 16, 2008
Posts: 138


its output is:
0
1
2
3
5
6
7
8
9
10
11
13
14
15

2nd code is:


its output is:
3
6
11
* will match 0 or more times
please explain difference in output
Rajeev Rnair
Ranch Hand

Joined: Mar 22, 2010
Posts: 308

First one is using "a*" which means 0 or more occurences of a. So it checks each and every character from 0 to length().
Second one is "aa*, which means "a" and THEN "a*". First there has to be "a" and then 0 or more occurences of "a". There are only 3 cases like that, hense the output is like that!

Hope this helps!


SCJP6, SCWCD5, OCP-JBCD5, OCE-JWSD6 OCE-JPAD6 , OCM-JEA5 1,OCM-JEA5 2,3 - Brainbench certifications: J2EE, Java2, Java2-NonGUI, JSP, SQL2000 Admin, SQL2000 Programming , Brainbench certified Java Programmer, Computer Programmer, Web Developer, Database Administrator
vineet walia
Ranch Hand

Joined: Feb 16, 2008
Posts: 138
thank you so much brother
vineet walia
Ranch Hand

Joined: Feb 16, 2008
Posts: 138
one more thing in first case
"oblaada oblaadi"
15 character

so why its is starting at 0 and end at 15(it should be at 14)?
Rajeev Rnair
Ranch Hand

Joined: Mar 22, 2010
Posts: 308

vineet walia wrote:one more thing in first case
"oblaada oblaadi"
15 character

so why its is starting at 0 and end at 15(it should be at 14)?

You are welcome mate!
This is a special case with the '*' meta character, and it always look after the last character! Please go through the K&B book chapter for Patterns and Regex.

Wish you all the best!

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: pattern matching