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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply 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: 3793
    
    1

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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: java.util.Matcher help please!
 
Similar Threads
MultiDimenaional Array sort
Regular expression to take integers out of a string
Doubt about Regex and Quantifiers
Chap:6 selftest q: 1 but in argument little more
Threads question