PDA

View Full Version : How to capture part of a string with double quotation marks



axiomcrs
08-02-2013, 08:17 AM
If I have this string:

+1. John Doe ("Johnny"), other data

I would like to capture:

John Doe ("Johnny")

using something like this:

re.Pattern = "^([\t\+][0-9]+\.\t)([.a-zA-Z \(\)""]+),"
Set mymatches = re.Execute(Rng.Text)
This syntax mymatches(0).SubMatches(1) should contain the desired portion of the string.

It won't the part of the string I am interested in. I have escaping it with a slash and doubling up the double quotation mark. But both don't work.
How do you specify to get the double quotation marks?

axiomcrs
08-02-2013, 02:52 PM
After much searching. I answered my own question.
MS VBScript Regular Expression 5.5 reference here http://msdn.microsoft.com/en-us/library/ms974570.aspx had the answer.
My new pattern has become:
re.Pattern = "(m\(1\) )([a-zA-Z \.\(\)\-\u201c\u201d\x22]+),"

The \u201c and \u201d are the relevant portions which will match a double left and right apostrophes.