Need to extract mobile numbers based on multiple words(LandLine|Mobile) scan from the below input. I am not able to extract all the 3 numbers. Need to read the number before and after the given words combination .Please assist
Words: (LandLine|Mobile)
String line = "i'm Joe my LandLine number is 987654321, another number 123456789 is my Mobile and wife Mobile number is 776655881";
String pattern = "(Mobile|LandLine)([^\\d]*)(\\d{9})|" //Forward read
+"(\\d{9})([^\\d]*)(Mobile|LandLine)"; //Backward read
Pattern r = Pattern.compile(pattern, Pattern.CASE_INSENSITIVE);
Matcher matcher = r.matcher(line);
while(matcher.find()) {
System.out.println(line.substring(matcher.start(), matcher.end()));
}
Code Output:
LandLine number is 987654321
123456789 is my Mobile and wife Mobile
Expected Output:
LandLine number is 987654321
123456789 is my Mobile
Mobile number is 776655881