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 30 31 32 33 34 35 36 37 38 39 40 41
|
Me.txtChamp(0).Text = NettoieChaine("[\u0009]|[\u000D]|[\u005C]", Me.txtChamp(0).Text)
'UNICODE :
' \u0009 Tabulation <TAB>
' \u000D Retour chariot <CR>
' \u005C Antislash
Function NettoieChaine(strPattern As String, strChaine As String) As String
'* -------------------------------------------------------------------'*
'* Vérification du contenu d'une chaine selon un pattern
'*
'* Paramètres en entrée :
'* --------------------
'* strPattern : modèle de chaine a supprimer
'* strChaine : chaine à vérifier
'*
'* Paramètres en sortie :
'* --------------------
'* Chaine corrigée
'*
'* -------------------------------------------------------------------'*
Dim regEx As RegExp, occurrences As MatchCollection, myMatch As Match
Set regEx = New RegExp
With regEx
.IgnoreCase = True
.global = True
.Pattern = strPattern
Set occurrences = .Execute(strChaine)
End With
For Each myMatch In occurrences
strChaine = Replace(strChaine, myMatch.Value, "")
Next
NettoieChaine = strChaine |
Partager