I'm having a whole text in a string and I want to find all belgium cell phone numbers.
So I wrote this piece of code:
Pattern cellPhoneRegex = Pattern.compile("^((\\+|00)32\\s?|0)4(60|[789]\\d)(\\s?\\d{2}){3}$");
List<String> cellPhoneList = new ArrayList<>();
Matcher cellPhoneMatches = cellPhoneRegex.matcher("+32495715511");
while (cellPhoneMatches.find()) {
cellPhoneList.add(cellPhoneMatches.group());
}
System.out.println(cellPhoneList);
Now the thing is that when you run this it matches the phone number. But when the same number is in a huge text it doesn't find anything.
For this string "Tel: +32495715511" there are no matches.
I don't see why it's not matching.