示例#1
0
		public static ContainsResult ContainsAnyWords(this string s1,
			List<string> anyOfThese, bool ignoreCase)
		{
			ContainsResult res = new ContainsResult();
			string[] s1Words = s1.SplitToWords();

			if (ignoreCase)
				s1Words = s1Words.Select(w => w.ToLower()).ToArray();

			List<string> anyOfTheseAdapted;

			if (ignoreCase)
				anyOfTheseAdapted = anyOfThese.Select(w => w.ToLower()).ToList();
			else
				anyOfTheseAdapted = anyOfThese;

			foreach (string word in anyOfTheseAdapted)
			{
				if (s1Words.Contains(word))
				{
					res.FoundWords.Add(word);
				}
			}

			return res;
		}
示例#2
0
		public static ContainsResult ContainsAny(this string s1, 
			List<string> anyOfThese, bool ignoreCase)
		{
			ContainsResult res = new ContainsResult();

			foreach (string word in anyOfThese)
			{
				if (s1.Contains(word, ignoreCase))
				{
					res.FoundWords.Add(word);
				}
			}

			return res;
		}