Given a string like the following:
"First there is a sentence or two, then a citation which I'd like to extract. Bookwriter, Johnny J., Book Title, 50th Edition, Publishing Company, United States, 2016, p. 18."
Using this regular expression:"\b[^\.\;]+(,\s+p+\.\s+(\d+\-\d+|\d+))"
I'm able to match this portion of the string:
"Book Title, 50th Edition, Publishing Company, United States, 2016, p. 18"
My desired match is:
"Bookwriter, Johnny J., Book Title, 50th Edition, Publishing Company, United States, 2016, p. 18"
To oversimplify it a bit, the current regex finds strings between a period and a page reference like ", p. 18" that doesn't have a semicolon or period in it.
I'd like to adjust this such that the regex permits a period to occur if it is preceded by a space and a capital letter. I'm aware that vba doesn't have lookbehind functionality.
The VBA code to run the example I've given is as follows:
Dim exampleString As String
exampleString = "First there is a sentence or two, then a citation which I'd like to extract. Bookwriter, Johnny J., Book Title, 50th Edition, Publishing Company, United States, 2016, p. 18."
Set re = CreateObject("vbscript.regexp")
With re
.Global = True
.pattern = "\b[^\.\;]+(,\s+p\.\s(\d+\-\d+|\d+))"
Set matches = .Execute(exampleString)
End With