View Single Post
 
Old 01-11-2013, 08:14 AM
tinfanide tinfanide is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2011
Posts: 312
tinfanide is on a distinguished road
Default Regular Expressions: match words within quotes?

I want to match
Quote:
images/folder 1/pic 009.JPG
in the following text:
Quote:
<gallery>
<pic path="images/folder 1/pic 009.JPG" desc="desc 1" />
<pic path="images/folder 1/pic 010.JPG" desc="desc 2" />
</gallery>
but it just matches the part (stated in the comments below in the codes)
Code:
Sub RegExp()

Dim oRegExp As RegExp
Dim oMatchCollection As MatchCollection
Dim oMatch As Match

Set oRegExp = New RegExp

''
oRegExp.Pattern = """.*JPG"""
'' return:
'' "images/folder 1/pic 009.JPG" desc="desc 1" /><pic path="images/folder 1/pic 010.JPG"

oRegExp.Global = True
oRegExp.IgnoreCase = True
'' oRegExp.MultiLine = False

Set oMatchCollection = oRegExp.Execute(ActiveDocument.Range)

For Each oMatch In oMatchCollection
    Debug.Print oMatch.Value
Next oMatch

Set oMatch = Nothing
Set oMatchCollection = Nothing
Set oRegExp = Nothing
End Sub
Reply With Quote