I have a String
InsertedTextAry NO AGREEMENT EXISTS FOR AGENCY - ABCD< 102354 This is test<
Now the requirement is to see if the text:
NO AGREEMENT EXISTS FOR AGENCY
... exists in the above text or not and if it does then extract the text:
NO AGREEMENT EXISTS FOR AGENCY - XXXX
The part after NO AGREEMENT EXISTS FOR AGENCY -
and before <
can be of any length consisting of numbers and/or alphabets.
I have done the search with the code
protected void testMethod(String text){
if(Pattern.matches(APPEND_FIRST + "NO AGREEMENT EXISTS FOR AGENCY" + APPEND_LAST, text)){
// do something
}
}
Now I need some help on how to extract the pattern NO AGREEMENT EXISTS FOR AGENCY - XXXX
(where XXXX
- can be of any length alphanumeric followed by <
).