wood burning stoves 2.0*
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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "question about regexp" Watch "question about regexp" New topic
Author

question about regexp

Johan Ee
Greenhorn

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);
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

Joined: Oct 13, 2005
Posts: 38100
    
  22
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
 
Similar Threads
How to mask string not conforming to a regular expression pattern
Address Book Java Issues
Mask - Format Record List Telephone Column
RegExp and conditional expression
regex (310-065)