@@ -26,9 +26,6 @@ public static bool AnyWildcardMatches(this string value, IEnumerable<string> pat
2626 if ( patternsToMatch == null || value == null )
2727 return false ;
2828
29- if ( ignoreCase )
30- value = value . ToLower ( ) ;
31-
3229 return patternsToMatch . Any ( pattern => IsPatternMatch ( value , pattern , ignoreCase ) ) ;
3330 }
3431
@@ -49,33 +46,18 @@ public static bool IsPatternMatch(this string value, string pattern, bool ignore
4946 bool endsWithWildcard = pattern . EndsWith ( "*" ) ;
5047 if ( endsWithWildcard )
5148 pattern = pattern . Substring ( 0 , pattern . Length - 1 ) ;
52-
53- if ( ignoreCase ) {
54- value = value . ToLower ( ) ;
55- pattern = pattern . ToLower ( ) ;
56- }
57-
49+
50+ var comparison = ignoreCase ? StringComparison . InvariantCultureIgnoreCase : StringComparison . InvariantCulture ;
5851 if ( startsWithWildcard && endsWithWildcard )
59- return value . Contains ( pattern ) ;
52+ return value . IndexOf ( pattern ?? "" , comparison ) >= 0 ;
6053
6154 if ( startsWithWildcard )
62- return value . EndsWith ( pattern ) ;
55+ return value . EndsWith ( pattern , comparison ) ;
6356
6457 if ( endsWithWildcard )
65- return value . StartsWith ( pattern ) ;
66-
67- return String . Equals ( value , pattern ) ;
68- }
69-
70- public static string [ ] SplitAndTrim ( this string input , params char [ ] separator ) {
71- if ( String . IsNullOrEmpty ( input ) )
72- return new string [ 0 ] ;
73-
74- var result = input . Split ( separator , StringSplitOptions . RemoveEmptyEntries ) ;
75- for ( int i = 0 ; i < result . Length ; i ++ )
76- result [ i ] = result [ i ] . Trim ( ) ;
58+ return value . StartsWith ( pattern , comparison ) ;
7759
78- return result ;
60+ return String . Equals ( value , pattern , comparison ) ;
7961 }
8062
8163 public static bool ToBoolean ( this string input , bool @default = false ) {
0 commit comments