PC Review


Reply
Thread Tools Rate Thread

Regular expression to find all string literals in my code?

 
 
Robin Tucker
Guest
Posts: n/a
 
      3rd May 2005
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

Thanks,



Robin


 
Reply With Quote
 
 
 
 
Larry Lard
Guest
Posts: n/a
 
      3rd May 2005

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

".*"

(which means: a quote mark, any number of {any character}, a quote
mark)

--
Larry Lard
Replies to group please

 
Reply With Quote
 
 
 
 
David
Guest
Posts: n/a
 
      4th May 2005
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




 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between string and string literals James Microsoft VB .NET 1 2nd Oct 2006 11:00 AM
Regular Expression Regex/Match fails if regular expression returns a null tdmailbox@yahoo.com Microsoft C# .NET 1 31st May 2005 02:19 AM
System::String * and string literals Ioannis Vranos Microsoft VC .NET 5 8th Apr 2005 09:14 AM
Customizing Regular Expression Editor for Regular Expression Validator Control Jason Timmerman Microsoft Dot NET Framework 0 27th Oct 2003 09:16 PM
Dynamically changing the regular expression of Regular Expression validator VSK Microsoft ASP .NET 2 24th Aug 2003 03:47 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:58 PM.