On 22/05/2014 10:04, [email protected] wrote:
I need to extract some information from source code.
How can I write a perl regular expression that will match a literal
string in languages like C#, javascript, java and lisp?
Here is my naive approach:
/"[^"]*"/
This of course does not accommodate backslashes in the string that perl,
C, C# javascript use.
"\"sdfds\"\\r\\t\\m".
How can I write a regular expression in perl to look for a double quoted
literal string in these languages?
There are many complications to something like this that can't be
properly resolved without parsing the language as a whole. However, this
/"(?:\\.|[^"])*"/
will cope with escaped quotes.
Rob
---
This email is free from viruses and malware because avast! Antivirus protection
is active.
http://www.avast.com
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/