Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

question about regexp

 
Johan Ee
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys!

So, i have this regexp:
Pattern p = Pattern.compile("^([A-Z]{2})_([A-Z]{1,2})([0-9]{2})-([0-9]{3,5}).(\\w+)");
Matcher matcher = p.matcher(aString);
if(matcher.matches())
....

So, if I get a match... How can I "collect" each one of these (from aString):
[A-Z]{2}) , ([A-Z]{1,2}), ([0-9]{2}), ([0-9]{3,5}), (\\w+)")
and put them in a variable??

thnx!
 
Campbell Ritchie
Sheriff
Pie
Posts: 49841
70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't know, but when I have that sort of problem, my first port of call will be the Java Tutorials.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic