1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| Sub telNb()
Dim reg
Dim obj
Dim txt()
txt = Array("01.35.08.99.52", _
"0135089952", _
"01-35-08-99-52", _
"01 35 08 99 52", _
"+331.35.08.99.52", _
"+33(0)1-35-08-99-52", _
"+33135089952", _
"331 35 08 99 52", _
"01/35/08/99/52", _
"01\35\08\99\52", _
"01,35,08,99,52", _
"331" & VBA.Chr(9) & "35" & VBA.Chr(9) & "08" & VBA.Chr(9) & "99" & VBA.Chr(9) & "52", _
"331" & VBA.Chr(10) & "35" & VBA.Chr(10) & "08" & VBA.Chr(10) & "99" & VBA.Chr(10) & "52", _
"331" & VBA.Chr(160) & "35" & VBA.Chr(160) & "08" & VBA.Chr(160) & "99" & VBA.Chr(160) & "52")
Set reg = CreateObject("VBScript.RegExp")
reg.Global = True
For Each obj In txt
reg.pattern = "(?:\+?\d{2} *(?:\(0\))? *|0)(\d[\s\-;,\.\\/" & VBA.Chr(160) & "]*(?:\d{2}[\s\-;,\.\\/" & VBA.Chr(160) & "]*){4})"
obj = reg.Replace(obj, "0$1")
reg.pattern = "(\d{2})[\s\-;,\.\\/" & VBA.Chr(160) & "]*"
obj = reg.Replace(obj, "$1 ")
Debug.Print obj
Next obj
End Sub |
Partager