Bonjour,
Je suis en train d'appliquer les expressions régulières dans VB
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
|
Sub Copy()
Dim i As Integer
Const MAX = 1000
Dim fileName As String
Dim objRegExp As RegExp
Dim objMatch As Object
Dim colMatches As MatchCollection
Dim retStr As String
Set objRegExp = New RegExp
objRegExp.IgnoreCase = True
objRegExp.Global = False
objRegExp.Pattern = "(\w+)\.xml\s"
For i = 1 To MAX
If Cells(i, 1) = "OK" Then
fileName = Cells(i, 7)
Set colMatches = objRegExp.Execute(fileName)
For Each objMatch In colMatches
MsgBox (objMatch.Value)
Next
End If
Next i
End Sub |
Par exemple quand fileName = C:\Nam\adfin\TestsXl\Regression\Store\Old\Bonds\AccruedYieldPrice\old_Px_Yld_Acc.xml
colMatches est toujours vide!
J'ai testé cet outil avec un outili et je vois qu'il n'y a pas de problème dans le syntax de l'expression régulière
J'ai essayé
objRegExp.Pattern = "(\\\\w+)\\.xml\\s"
Mais ça ne marche toujours pas
Merci de votre aide
Partager