• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.util.Matcher help please!

 
Mark Baldwin
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4568
9
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It did. Thanks friend. Regexp isn't my forte
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic