aspose file tools*
The moose likes Java in General and the fly likes java.util.Matcher help please! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "java.util.Matcher help please!" Watch "java.util.Matcher help please!" New topic
Author

java.util.Matcher help please!

Mark Baldwin
Greenhorn

Joined: Aug 04, 2011
Posts: 9
Hi all,

java.util.regex.Matcher doesn't seem to be working the way I want it to work:



Expected output:



Output:



What's up with this?
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4421
    
    8

Because you've got the .* at the beginning and end, the pattern will match against the entire string. Maybe a simpler expression like "@([a-zA-Z_0-9]*)@" would do what you want?
Mark Baldwin
Greenhorn

Joined: Aug 04, 2011
Posts: 9
It did. Thanks friend. Regexp isn't my forte
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.util.Matcher help please!