public static string CheckNamesAndConstants(string s)
{
var rege = @"(?>[_.a-zA-Z0-9]+)"; // ?> forces the regex engine to not backtrack, ?!\( ensures that the word does not end with ( which would make it a function name
var matches = Regex.Matches(s,rege);
if (matches.Count>0)
{
for (int i=0;i<matches.Count;i++)
{
var m = matches[i].Value;
if (!IsValidNameOrConstant(m))
{
return m;
}
}
}
return null;
}