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
| Dim alValue(5),ahValue(5)
iValue=1236
hValue = iValue + 5
lValue= iValue - 5
sValue=CStr(Int(lValue))
p = 1
For i = 7 - Len(sValue) to 6
alValue(i-1)=Mid(sValue,p,1)
p = p + 1
Next
sValue=CStr(Int(hValue))
p = 1
For i= 7 - Len(sValue) to 6
ahValue(i-1)=Mid(sValue,p,1)
p = p + 1
Next
Set regEx = New RegExp
regEx.Pattern = "(" & alValue(0) & alValue(1) & alValue(2) & "|" & ahValue(0) & ahValue(1) & ahValue(2) & ")*" & "(\.|,| )?" & _
"(" & alValue(3) & alValue(4) & "[" & alValue(5) & "-9]|" & ahValue(3) & ahValue(4) & "[0-" & ahValue(5) & "])+" & "(\.|,)(\d+)"
regEx.IgnoreCase = False
regEx.Global = True
Set Matches = regEx.Execute("7874585 xx 102.3 az 115.4 cd 12345.90 rtft 581,234.21 ou 1.231,74 qa 1234.50 ou 1 234,50 ou 1.234,50 ou 1234,50 rper 521,24 aa 2,55")
For Each Match in Matches 'Itère la collection Matches.
Result=regEx.Replace(Match.Value,"$1$3")
MsgBox Result
Next |
Partager