aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Matcher.find() ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply locked New topic
Author

Matcher.find() ?

Hans Beck�rus
Greenhorn

Joined: Aug 23, 2006
Posts: 24
I have some issues understanding the logic implemented by the find()/start() methods in class Matcher .

Hans Beck�rus
Greenhorn

Joined: Aug 23, 2006
Posts: 24
Sorry by browser comitted the post before it was complete,
can you check my new post?
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

You are looking for a certain pattern in your string. There may be several substrings matching that pattern. Each call to find() will get you the next substring matching that pattern. start() will then return the index of that substring (the first character of it in the whole string) and group() will give you the substring.

The problem here is that "*" matches the empty string too.

Try this instead to see it in action:


[My Blog]
All roads lead to JavaRanch
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

PS : Maybe wou wanted to use '+' instead of '*'
Hans Beck�rus
Greenhorn

Joined: Aug 23, 2006
Posts: 24
No, I wanted to use *, the problem is not undertstanding patterns
themselves, it is the output of the code that confuses me.
As said, this post is obsolete, it was comitted before I managed
to finish it I made another post with the same title.
Please check that for my "real" question.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Matcher.find() ?