views:

53

answers:

1

Hi, I'm looking for a fast .NET class/library that has a StringComparer that supports wildcard (*) AND incase-sensitivity. Any Ideas?

+3  A: 

You could use Regex with RegexOptions.IgnoreCase, then compare with the IsMatch method.

var wordRegex = new Regex( "^" + prefix + ".*" + suffix + "$", RegexOptions.IgnoreCase );

if (wordRegex.IsMatch( testWord ))
{
    ...
}

This would match prefix*suffix. You might also consider using StartsWith or EndsWith as alternatives.

tvanfosson