/// <summary> /// Checks the series trash value. Regex : https://regex101.com/r/wqdBKT/1 /// </summary> /// <param name="valueFromTextBox">The value from text box.</param> /// <param name="table">The table.</param> /// <returns> /// <c>true</c> if [is serries trash value] [the specified value from text box]; otherwise, <c>false</c>. /// </returns> private bool IsSerriesTrashValue(string valueFromTextBox, Dlv005DataSet.BD12_BAUREIHEDataTable table) { char[] delimiterChars = { ',', ';', '`' }; string[] words = valueFromTextBox.Split(delimiterChars); int matchedValues = 0; foreach (DataRow row in table) { if (Regex.Matches(valueFromTextBox, "(^" + row["Series"] + "($|[;',][0-9a-zA-Z]))|([;',])(" + row["Series"] + "($|[;',][0-9a-zA-Z]))|([;',])(" + row["Series"] + ")($)").Count == 1) { matchedValues++; } } return(matchedValues == words.Length); }
/// <summary> /// Validates the series. /// </summary> /// <param name="valueFromTextBox">The value from text box.</param> /// <param name="table">The table.</param> /// <returns></returns> private bool TrashSeries(string valueFromTextBox, Dlv005DataSet.BD12_BAUREIHEDataTable table) { return(Regex.Matches(valueFromTextBox, @"[a-zA-Z]").Count != 0 || !IsSerriesTrashValue(valueFromTextBox, table)); }