I have a file that contains phone numbers and would like to create a csv file out of it.
The issue I face is that the format is not fixed and not easy to parse.
- Each row contains one, two or three phone records.
- A phone might start or not with (+xxx) and the second phone might be preceded of the '&' or not.
I was trying to built a regex that could split each row in 3 groups and then find/replace into the expected format but without success.
Anyone could come up with an regex that could identify each group per row?
Input
(+999) 11 762 52 61 (+999) 11 762 41 11
(+999) 44 695 01 76 & 44 695 01 89
(+999) 21 510 02 14 (+999) 21 511 97 98
(+999) 01 05 00 18 67
(+999) 21 552 42 12
(+999) 21 557 86 60 (+999) 21 557 86 72
(+999) 11 873 93 13 & 11 825 59 92
(+999) 15 307 57 15 & 15 307 57 16 & (+999) 11 974 19 57
(+999) 21 551 91 51 (+999) 21 551 91 68
(+999) 21 551 71 71 & 21 551 72 32
(+999) 21 527 30 00 (+999) 21 551 54 89
(+999) 11 621 15 00 (+999) 11 626 20 75
(+999) 21 555 21 60 (+999) 21 555 21 71 (+999) 12 804 76 30
(+999) 11 234 18 96 (+999) 11 234 54 48
(+999) 11 828 35 37 (+999) 11 828 63 76 (+999) 41 363 27 23
(+999) 11 690 03 00 (+999) 11 315 65 38
(+999) 08 32 60 34 65
(+999) 08 32 60 34 65 & (+999) 11 784 46 70 & (+999) 11 784 61 79
Expected Result:
(+999) 11 762 52 61, (+999) 11 762 41 11,
(+999) 44 695 01 76, 44 695 01 89,
(+999) 21 510 02 14, (+999) 21 511 97 98,
(+999) 01 05 00 18 67,,
(+999) 21 552 42 12,,
(+999) 21 557 86 60, (+999) 21 557 86 72,
(+999) 11 873 93 13, 11 825 59 92,
(+999) 15 307 57 15, 15 307 57 16, (+999) 11 974 19 57
(+999) 21 551 91 51, (+999) 21 551 91 68,
(+999) 21 551 71 71, 21 551 72 32,
(+999) 21 527 30 00, (+999) 21 551 54 89,
(+999) 11 621 15 00, (+999) 11 626 20 75,
(+999) 21 555 21 60, (+999) 21 555 21 71, (+999) 12 804 76 30
(+999) 11 234 18 96, (+999) 11 234 54 48,
(+999) 11 828 35 37, (+999) 11 828 63 76, (+999) 41 363 27 23
(+999) 11 690 03 00, (+999) 11 315 65 38,
(+999) 08 32 60 34 65,,
(+999) 08 32 60 34 65, (+999) 11 784 46 70, (+999) 11 784 61 79
(& \(|[&(]+)maybe?