On Wed, 20 Aug 2008 12:17:04 -0400, "eBob.com"
<eB******@total lybogus.comwrot e:
>Hi Seth,
Thanks for responding. I am a HUGE fan of Expresso. But in my experience
it has one major flaw - it hasn't made me any smarter! Expresso has helped
me to eliminate all of the dumb ideas I've had so far. But I am not finding
a pattern which is air tight. My latest idea, forgetting for the moment
that almost any character can occur in a string, is ...
"[\w("")]+"
... and that does match
"some""mo""re" ""
However, it also matches ...
"some""mo"re"" "
... which of course it should not. I don't understand how it matches the
first case and the second case. In the first case it does seem to be
treating the double double-quotes as a single character, otherwise I'd get
more than one match. But then in the second case it is perfectly happy to
have one double-quote in the string which does not terminate the match.
So despite Expresso I am still looking for a pattern which will match a VB
string.
Bob
Forget about trying to do this with a single regular expression.
You're not going to have success.
What I suggest you do is split this up into three steps:
1. All VB strings start and end with double quotes, so remove them.
2. With the remaining text, temporarily replace all double quotes
with other characters. So, "some ""more"" text" will become
"some \quotemore\quot e text".
3. Test if the text is now a valid VB string. You can do this with
a simple regular expression like: ^(?!.*").*$
This that expression does not match, it's not a valid string.
You have all text for the string now if the text was a valid string.
You really do not have another choice, since you cannot use balanced
group matching (the beginning " is identical to the ending ", so you
cannot differentiate starting and ending strings unless you replace
all "" characters with something else).