On 2005-05-03, Larry Lard <(E-Mail Removed)> wrote:
>
> Robin Tucker wrote:
>> Hiya,
>>
>> Regular expressions always do my gnads in - can anyone cook up a reg
>> expression to find all string literals in my code? I would like to
> put them
>> into a resource file for future translation 
>
> How about
>
> ".*"
Regexes are greedy by default, so that wouldn't work, you'd match once from
the first quote in the file to the last. You really want...
".+?"
or
"[^"]+"
(plusses instead of stars since we probably don't want the empty string)
Although to be honest, neither of those will work correctly either.
I'm not sure that this problem is truly solvable by a regex. The problem
is correctly matching embedded quotes, things like
Dim s as string = "The first thing ""we"" do is kill all the ""lawyers"""
I'm not sure how to match that in a regex.
David