Contact Yart for a relaxed conversation
Your Name * Message *
Your Email *  
Your Phone   
Our Phone:        03 8685 8718 (within Australia)
61 3 8685 8718 (outside Australia)
Contact Yart

Melbourne Content Management and Flash developers

 

for designers, agencies and your website

Resources / Programming / Find Quoted String Regular Expressions
Find A String Between Quotes With Regular Expressions

I must have written this regular expression many times, but each time I go back to it it seems like I have to search through Google for help on regular expressions - their syntax is so obtuse.

This expression finds the string between double quote marks after an XML attribute.

string contents = "    CodeFile=\"abc\"       ";

Match filenameMatch = Regex.Match(contents, "CodeFile=\"(?<CodeFile>[^\"]*)\"");

if (filenameMatch.Success)
{
//returns abc
filename = filenameMatch.Groups["CodeFile"].Value;
}

 

The latest at Yart
Search: