Tout Caractère doit être précédé de \ pour que le pattern fonction en théorie même l'espace.
c'est OK avec "\:"
Const texte = "\-\\\*-****/Un test, Pourquoi faire? c'est fou: ça! \****-*///*/"
Dim objDico
Dim myarray, arrDicoItem
Dim item, strList, cprovisoire
Dim i, t, bpermute
myarray = Array("\?", "\ ", "\,", "\*", "\!", "\\", "\-", "\:", "\'")
Set objDico = CreateObject("Scripting.Dictionary")
For Each item In myarray
Recherche(item)
Next
' Tri
arrDicoItem = objDico.Items
bpermute = True
Do While bpermute = True 'Il faut au moins parcourir une fois
bpermute = False 'On tourne tant que l'on bouge des valeurs
For t = 0 To UBound(arrDicoItem) -1
If CInt(Split(arrDicoItem(t),": ")(1)) > CInt(Split(arrDicoItem(t + 1),": ")(1)) Then
cprovisoire = arrDicoItem(t)
arrDicoItem(t) = arrDicoItem(t + 1)
arrDicoItem(t + 1) = cprovisoire
bpermute = True
End If
Next
Loop
'Affichage du résultat classé
strList = objDico.Count & " correspondance(s) trouvée(s):" & vbcrlf
For i = 0 To UBound(arrDicoItem)
strList = strList & "(" & i+1 & ")" & " " & arrDicoItem(i) &vbCrLf
Next
Set objDico = Nothing
MsgBox strList,,"Liste"
WScript.Quit
Sub Recherche(Caractere)
Dim regex, matches
Dim Pattern, match, i
Pattern = "([^" & Caractere & "]|^)(" & Caractere & ")(?!" & Caractere & ")"
Set regex = New RegExp
regex.Pattern = Pattern
regex.Global = True
Set matches = regex.Execute(texte)
For Each match In matches
For i = 1 To match.Submatches.Count - 1 Step 2
If Not (match.Submatches(i) = "") Then
objDico.Add match.FirstIndex + Len(match.Value) - 1, _
"Correspondance trouvée """ & _
match.Submatches(i) & """ en position: " & _
match.FirstIndex + Len(match.Value) - 1
End If
Next
Next
Set matches = Nothing
Set regex = Nothing
End Sub