@@ -26,9 +26,6 @@ public static bool AnyWildcardMatches(this string value, IEnumerable<string> pat
26
26
if ( patternsToMatch == null || value == null )
27
27
return false ;
28
28
29
- if ( ignoreCase )
30
- value = value . ToLower ( ) ;
31
-
32
29
return patternsToMatch . Any ( pattern => IsPatternMatch ( value , pattern , ignoreCase ) ) ;
33
30
}
34
31
@@ -49,33 +46,18 @@ public static bool IsPatternMatch(this string value, string pattern, bool ignore
49
46
bool endsWithWildcard = pattern . EndsWith ( "*" ) ;
50
47
if ( endsWithWildcard )
51
48
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 ;
58
51
if ( startsWithWildcard && endsWithWildcard )
59
- return value . Contains ( pattern ) ;
52
+ return value . IndexOf ( pattern ?? "" , comparison ) >= 0 ;
60
53
61
54
if ( startsWithWildcard )
62
- return value . EndsWith ( pattern ) ;
55
+ return value . EndsWith ( pattern , comparison ) ;
63
56
64
57
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 ) ;
77
59
78
- return result ;
60
+ return String . Equals ( value , pattern , comparison ) ;
79
61
}
80
62
81
63
public static bool ToBoolean ( this string input , bool @default = false ) {
0 commit comments