NeriXs
Messages postés227Date d'inscriptionlundi 4 mai 2015StatutMembreDernière intervention 7 décembre 2023
-
21 déc. 2017 à 08:29
NeriXs
Messages postés227Date d'inscriptionlundi 4 mai 2015StatutMembreDernière intervention 7 décembre 2023
-
21 déc. 2017 à 15:45
Bonjour,
J'essaie de récupérer le résultat de mon remplacement dans mon message de sortie afin d'obtenir ceci:
Const texte:
\-\\\*-****/Un test, Pourquoi faire? c'est fou ça! \****-*///*/
Result:
\(-)\\\(*)(-)****(/)Un( )test(,)( )Pourquoi( )faire(?)( )c(')est( )fou( )ça(!)( )\****(-)(*)///(*)(/)
Pouvez-vous m'aider?
Const texte = "\-\\\*-****/Un test, Pourquoi faire? c'est fou ça! \****-*///*/"
Dim objDico Dim myarray, arrDicoItem Dim item, strList, cprovisoire Dim i, t, bpermute
bpermute = True Do While bpermute = True bpermute = False 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
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
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
'####################################################### result = regex.Replace(texte, "($2)") MsgBox result '#######################################################
21 déc. 2017 à 15:45