Below Python example will use the re module to group the telephone number without the ‘-‘ sign and the period ‘.’.
Let’s say the phone number has been written in this manner.
The below python program will group the numbers by taking out both the ‘-‘ sign and ‘.’.
find = re.compile(r'\d+(?=\-|\.)') match = find.findall('123-456-7810.')
The match array now stored the following numbers:-
['123', '456', '7810']
Next what if I just want to extract all the numbers without the ‘-‘ sign? Then use the below program.
find = re.compile(r'\d+(?!\d)') match = find.findall('123-456-7810')