I want to get flashvars from a string which is in the code below.
But at the end of the code the matched value comes with other attributes like pluginspage.
How can I fix it?
Am I wrong with my regex?
Here is my code:
string source = "<embed src=\"http://godtube.com/flvplayer.swf\" FlashVars=\"videoThumb=http://www.godtube.com/thumb/1_30772.jpg&flvPath=http://www.godtube.com/flvideo1/47/30772.flv\" wmode=\"transparent\" quality=\"high\" width=\"330\" height=\"270\" name=\"flv_demo\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" /></embed>";
Regex sRgx = new Regex("flashvars=\"(.*)\"", RegexOptions.Multiline);
Match regexMatch = sRgx.Match(source);
if (regexMatch.Success)
{
string matched = regexMatch.Groups[1].Value;
}
Try with this:
The
?makes the regex to match the shortest possible match, otherwise the .* will crunch everithing to the end of the string.