I am trying to extract the bold substring from the following string using Java regex:
music works | with | composer | James Hetfield (musician)
I got started with this code, but this does not work. I am not sure what I am missing:
final Pattern pattern = Pattern.compile("| (.+?) (musician)");
final Matcher matcher = pattern.matcher("music works | with | composer | James Hetfield (musician)");
matcher.find();
System.out.println(matcher.group(1)); // Prints String I want to extract
Thoughts?