import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "\\b\\w*_P\\w*\\h+\\w*_V\\w*(*SKIP)(*F)|\\b\\w*_V\\w*";
final String string = "Ya_UH and_CC then_RT uhm_NN1 we_PPIS2 wrote_VVD in_RP but_CCB already_RR taken_VVN up_RP that_DD1 day_NNT1 that_CST we_PPIS2 wanted_VVD actually_RR they_PPHS2 said_VVD still_RR available_JJ you_PPY know_VV0 so_RR by_II that_DD1 time_NNT1 we_PPIS2 we_PPIS2 write_VV0 in_II our_APPGE letter_NN1 two_MC weeks_NNT2 later_RRR already_RR taken_VVN up_RP Quite_RG good_RR uh_UH P ICE-SIN:S1A-001#74:1:B Ask_VV0 her_PPHO1 I_PPIS1 left_VVD my_APPGE house_NN1 at_II one_MC1 met_VVD PRO_NN1 in_II school_NN1 at_II two_MC Ya_PPY so_RR waited_VVD you_PPY know_VV0 they_PPHS2 say_VV0 half_DB hour_NNT1 later_RRR And_CC and_CC it_PPH1 was_VBDZ still_RR drizzling_JJ and_CC raining_VVG";
final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
final Matcher matcher = pattern.matcher(string);
while (matcher.find()) {
System.out.println("Full match: " + matcher.group(0));
for (int i = 1; i <= matcher.groupCount(); i++) {
System.out.println("Group " + i + ": " + matcher.group(i));
}
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Java, please visit: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html