Need a compound expression for
\" from\" such that \" from\" is not within parenthesis
(ignoring those which are in parenthesi
This may be what you want.
string s="select field1 dfd t1 (select field1 from t1)select field1 from t1"; Regex r=new Regex(@"(?<=\)|^)\bselect\b.*?\bfrom\b.*?(?=\()",RegexOptions.RightToLeft); r.Replace(s,"HELL yeah");