[ignore]How do I modify the code (or the reg. expression) below, so that I get :
groupStr0 = "
groupStr1 = &
groupStr2 = '
groupStr3 = <
instead of only:
groupStr0 = "
*************************************************'
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class PatternTest {
public static void main(String[] args) {
String testData = "" tada dum di & dum ' dum; < dum dum tada";
Pattern p = Pattern.compile("(&\\w+");
Matcher matcher = p.matcher(testData);
boolean matchFound = matcher.find();
if (matchFound) {
// Get all groups for this match
for (int i = 0; i < matcher.groupCount(); i++) {
String groupStr = matcher.group(i);
System.out.println("groupStr" + i + " = " + groupStr);
}
}
}
}
[/ignore]
groupStr0 = "
groupStr1 = &
groupStr2 = '
groupStr3 = <
instead of only:
groupStr0 = "
*************************************************'
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class PatternTest {
public static void main(String[] args) {
String testData = "" tada dum di & dum ' dum; < dum dum tada";
Pattern p = Pattern.compile("(&\\w+");
Matcher matcher = p.matcher(testData);
boolean matchFound = matcher.find();
if (matchFound) {
// Get all groups for this match
for (int i = 0; i < matcher.groupCount(); i++) {
String groupStr = matcher.group(i);
System.out.println("groupStr" + i + " = " + groupStr);
}
}
}
}
[/ignore]