import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "(\\bbod\\S*)|(embodi\\S*)";
final String string = "Fancher: what does Eugene teach us about embodiment (for disembodied chatter bot) and intelligence? #RSA16\n\n"
+ "Faris: And in spite of turns to embodiment and sensation, little on eros of bodies #o15 #rsa16\n\n"
+ "Kerschbaum: Embodiment and embodied knowledge is always embedded with our decisions and navigations of spaces. #rsa16\n\n"
+ "#yesallwomen shows digital embodiment through storytelling. #g19 #RSA16 @RCMeg\n\n"
+ "Virtual is an extension of the corporeal body. We must pay attention to movement. To embodiment. #RSA16 #g19\n\n"
+ "#i5 #RSA16 @DrJenTalbot parrhesia assumes static notions of embodiment and power";
final Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
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