Sunday, November 27, 2011

Get all words starts from @

We can use following regrular expression for fetch all words start with @

Regex MyList = new Regex(@"@(?<vKey>[\w\.]+)");//

Sample code :


List
<string> NameList = new List<string>();Regex MyList = new Regex(@"@(?<vKey>[\w\.]+)");//if this is not working than put slash before "@"



{
MatchCollection myMatches = MyList.Matches(TextBoxSQLQuery.Text.Trim(), 0);StringBuilder sb = new StringBuilder();string syntax = TextBoxEbaseParameter.Text.Trim() + "(\"@";foreach (Match myMatch in myMatches)string varName = myMatch.Groups["vKey"].Value;}

Thanks
Mahesh Kumar Sharma

No comments: