RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
"([^"](?:\\.|[^\\"]*)*)"
Description
Matches C style strings allowing for escaped string delimiters to be included in the match. ALTERED 13-Dec-2003 ------------------- Previous pattern was : "([^"](?:\\.|[^\\"]*)*)" Changed to: "([^"]*(?:\\.|[^\\"]*)*)" Making the first character after the opening quote optional allows the pattern to match on empty quotes: "".
Matches
"This is a \"string\"."
Non-Matches
"This is a \"string\".
Author Rating: The rating for this expression. Darren Neimke
Source
Your Rating
Bad Good

Enter New Comment

Title
 
Name
 
Comment
 
Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Title: If the escape character will be that "
Name: Serge
Date: 11/13/2006 7:52:12 AM
Comment:
If the escape character will be that? Exemple "This is a ""String"


Title: If the escape character will be that?
Name: If the escape character will be that?
Date: 11/13/2006 7:51:01 AM
Comment:
If the escape character will be that? Exemple "This is a ""String"


Title: developer
Name: Vlad
Date: 8/9/2005 11:30:49 PM
Comment:
thanks. btw, it works even better without first [^"], try: "((?:\\.|[^\\""]*)*)". Changing [^"] to [^"]* kills it.


Title: String literals
Name: Shanmugam Devaraj
Date: 6/23/2005 11:13:33 PM
Comment:
If we need to match string literals, a simple expression like below should be sufficient isn't it? expression = "^".*"$" i.e.Begin with double quote and end with double quote and match any characters zero or more times. This would match "", """, " ", "test\", "\"test\"", ""test"", ""ErrorMessageCode",1249", "This is a \"string\"." etc...


Title: Thanks Gideon
Name: Darren Neimke
Date: 4/2/2005 11:05:55 PM
Comment:
I'll check this out during the week and then modify my pattern accordingly. Thankyou for taking the time to give me the feedback!


Title: Simpler solution
Name: Gideon Engelberth
Date: 4/2/2005 7:55:25 PM
Comment:
Darren, your modification does allow the expression to match the empty string, but it also now matches "test\" While Benoit's solution also seems to work, here is a simpler expression that meets the specifications. "(?:\\.|[^\\"])*"


Title: Empty strings solution!
Name: Benoit d'Oncieu
Date: 3/5/2004 6:10:27 AM
Comment:
Darren Solution does not work as it would match the following: """ The correct regex is: "([^"](?:\\.|[^\\"]*)*)?"


Title: Re: x
Name: Darren Neimke
Date: 12/12/2003 2:39:34 PM
Comment:
ALTERED 13-Dec-2003 ------------------- Previous pattern was : "([^"](?:\\.|[^\\"]*)*)" Changed to: "([^"]*(?:\\.|[^\\"]*)*)" Making the first character after the opening quote optional allows the pattern to match on empty quotes: "".


Title: x
Name: Achim
Date: 12/12/2003 3:55:50 AM
Comment:
This expression dowa not work for empty strings ""! Any suggestion how to solve this problem?


Copyright © 2001-2018, RegexAdvice.com | ASP.NET Tutorials