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
| TxtSource = "Un test? Pourquoi faire? c'est fou ça?"
ReslutSpeciChars = ""
Dim strText, RegularExpressioN
FindSpeciChars = "(\\)|(\/)|(\*)|(\+)|(\-)|(\=)|(\?)|(\!)|(\:)|(\;)|(\,)|(\')|(\&)|(\~)|(\{)|(\})|(\()|(\))|(\[)|(\])|(\@)|(\^)|(\¨)|(\$)|(\£)|(\)|(\.)|(\<)|(\>)|(\|)"
strText = TxtSource
Set RegularExpressioN = New RegExp
RegularExpressioN.Pattern = FindSpeciChars
RegularExpressioN.Global = True
Set Matches = RegularExpressioN.Execute(strText)
If Matches.Count > 0 Then
MatchMsg = Matches.Count & " correspondance(s) trouvée(s)." & vbCRLF
For Each Match In Matches
MatchMsg = MatchMsg & "Correspondance trouvée """ & Match.Value & """ en position: " & Match.FirstIndex & vbCrLf
Next
'MsgBox MatchMsg
Else
MsgBox "Aucun match", 0, "VBScript RegExp Tester"
End If
strText = RegularExpressioN.Replace(strText, "$7$12")
Set RegularExpressioN = Nothing
ReslutSpeciChars = strText
MsgBox TxtSource & vbCrLf & ReslutSpeciChars & vbCrLf & MatchMsg |
Partager