I have a string like this :
"value of <abc/def> ends with <def> and value of <abc/def> does not end with <abc> and value of <abc> is <abc>"
I want to extract the string value of <abc/def> does not end with <abc>
.
I used following pattern
String text = "value of <abc/def> ends with <def> and value of <abc/def> does not end with <abc> and value of <abc> is <abc>";
String patternString1 = "(value\\s+of\\s+(<.*>)\\s+ends\\s+with\\s+(<.*>))";
Pattern pattern = Pattern.compile(patternString1);
Matcher matcher = pattern.matcher(text);
while(matcher.find()) {
System.out.println("found: " + matcher.group(1));
}
Results :-
found: value of <abc/def> ends with <def> and value of <abc/def> does not end with <abc> and value of <abc> is <abc>