using System.Text.RegularExpressions;
public static void Main()
string file = @"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD";
var regex = new Regex(@"^data:(.*);base64");
var matches = regex.Matches(file);
foreach (Match match in matches)
GroupCollection groups = match.Groups;
Console.WriteLine(groups[1].Value);