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 Badass: Making Users Awesome this week in the Game Development forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "java.util.Matcher help please!" Watch "java.util.Matcher help please!" New topic

java.util.Matcher help please!

Mark Baldwin

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:


What's up with this?
Matthew Brown

Joined: Apr 06, 2010
Posts: 4518

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

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