jQuery in Action, 3rd edition
The moose likes Java in General and the fly likes question about regexp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "question about regexp" Watch "question about regexp" New topic

question about regexp

Johan Ee

Joined: May 24, 2008
Posts: 4
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);

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??

Campbell Ritchie

Joined: Oct 13, 2005
Posts: 45359
Don't know, but when I have that sort of problem, my first port of call will be the Java Tutorials.
I agree. Here's the link: http://aspose.com/file-tools
subject: question about regexp
It's not a secret anymore!