File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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: 46356
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:
subject: question about regexp
It's not a secret anymore!