What you're looking for is called capturing group in java regex.
e.g. for this input: "world cup, football, asia, 2011"
- when you apply this regEx: "^world cup, football, ([^,]*), 2011$"
- then matcher.group(1) is set to "asia"
- when you apply "^world cup, ([^,]*), ([^,]*), 2011$"
- then matcher.group(1) is set to "football" and matcher.group(2) is set to "asia".
See javadoc/google for examples. You need to use Pattern.compile(), Pattern.mathcer() and matcher.group() methods.
thekashyap
Practically a Posting Shark
811 posts since Feb 2007
Reputation Points: 254
Solved Threads: 75