I'm trying to search my datatable for a possible string pattern. For example I want to search the term "nin" in column A of my datatable, I want it to show all of the rows which has the pattern "nin", even if it is in uppercase or in other format. What I'm currently doing is this:
for(var f = 0; f < dt.Rows.Count; f++)
{
string temp = "nin";
string PositionName = dt.Rows.[f]['ColumnA'].ToString();
int tempColCount = PositionName.Length;
bool searchTerm = PositionName.Substring(0, tempColCount).Contains(temp);
}
But all I'm getting are rows that have the exact pattern as "nin". How do I get the other formats of the same pattern? I'm thinking something like Regex here but I can't understand the tutorials online.
Fast way to search for, depending on culture an ignoring upper / lower:
CompareInfo compInf = CultureInfo.CurrentCulture.CompareInfo;
int compResult = compInf.IndexOf(searchInString, searchForString, CompareOptions.IgnoreCase);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.