Check the below code :
string test = "Sql==SqlString && Sql!=OracleStr || A==b&&b!=c&&D==m";
List<string> Variables = new List<string>();
MatchCollection Matches = Regex.Matches(test, @"(\w+)[=!]+(\w+)", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.IgnoreCase);
foreach (Match ma in Matches)
{
if (!Variables.Contains(ma.Groups[1].Value))
Variables.Add(ma.Groups[1].Value);
if (!Variables.Contains(ma.Groups[2].Value))
Variables.Add(ma.Groups[2].Value);
}</string></string>