Le modèle peut être .: (Section \d+[\r\n])(\w+(?: \w+)?)
par exemple.
Le premier groupe de capture intercepte la première ligne (Section, numéro et nouvelle ligne).
Le deuxième groupe de capture obtient la note (un ou deux mots) et c'est ce dont vous avez réellement besoin. Ci-dessous vous trouverez un exemple de script, coché (utilisé comme macro) sur un document Word.
Sub Re()
Dim pattern As String: pattern = "(Section \d+[\r\n])(\w+(?: \w+)?)"
Dim regEx As New RegExp
Dim src As String
Dim ret As String
Dim colMatches As MatchCollection
Dim objMatch As Match
ActiveDocument.Range.Select
src = ActiveDocument.Range.Text
Selection.StartOf
With regEx
.Global = True
.MultiLine = True
.pattern = pattern
End With
If (regEx.Test(src)) Then
Set colMatches = regEx.Execute(src)
ret = "Matches " & colMatches.Count & ": "
For Each objMatch In colMatches
ret = ret & vbCrLf & objMatch.SubMatches(1)
Next
Else
ret = "Matching Failed"
End If
MsgBox ret, vbOKOnly, "Result"
End Sub
Merci beaucoup! C'est exactement ce que je cherche! –