19 using System.Collections.Generic;
21 namespace Lucene.Net.Search.Vectorhighlight
23 public static class StringUtils
28 public static Boolean TermStringMatch(String term, String termToMatch)
30 if (term[0] ==
'*' || term[0] ==
'?')
31 throw new NotSupportedException(
"Unable to do matching with wildcard at the beginning");
33 if (term[term.Length - 1] ==
'*')
36 if (termToMatch.Length < term.Length - 1)
return false;
37 for (
int i = 0; i < term.Length - 1; i++)
39 if (termToMatch[i] != term[i])
return false;
43 return term.Equals(termToMatch);
46 public static Boolean AnyTermMatch(IList<String> terms, String term)
48 for (
int i = 0; i < terms.Count; i++)
50 if (StringUtils.TermStringMatch(terms[i], term))