* Handle a wildcard match that contains a forward slash in the pattern by adding / to the delimiter list of preg_quote * Fix SUMIF doing a wildcard match on empty cells (NULL) * Fix compare logic to return false when value is an empty string or NULL (Verified against LibreOffice SUMIF and MATCH handling of empty cells)
This commit is contained in:
parent
3918f626cc
commit
e01a81ec5e
|
|
@ -25,13 +25,13 @@ class WildcardMatch
|
|||
public static function wildcard(string $wildcard): string
|
||||
{
|
||||
// Preg Escape the wildcard, but protecting the Excel * and ? search characters
|
||||
return str_replace(self::SEARCH_SET, self::REPLACEMENT_SET, preg_quote($wildcard));
|
||||
return str_replace(self::SEARCH_SET, self::REPLACEMENT_SET, preg_quote($wildcard, '/'));
|
||||
}
|
||||
|
||||
public static function compare(string $value, string $wildcard): bool
|
||||
public static function compare(?string $value, string $wildcard): bool
|
||||
{
|
||||
if ($value === '') {
|
||||
return true;
|
||||
if ($value === '' || $value === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (bool) preg_match("/^{$wildcard}\$/mui", $value);
|
||||
|
|
|
|||
|
|
@ -352,4 +352,10 @@ return [
|
|||
['aAAAAA', 'a123456*c', 'abc~xyz', 'alembic'],
|
||||
0,
|
||||
],
|
||||
[
|
||||
2, // Expected
|
||||
'abc/123*', // wildcard search contains a forward slash
|
||||
['abc123fff', 'abc/123fff'],
|
||||
0,
|
||||
],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -168,4 +168,16 @@ return [
|
|||
'n',
|
||||
[[1], [2], [3], [4], [5], [6], [7], [8], [9]],
|
||||
],
|
||||
[
|
||||
2,
|
||||
[
|
||||
[null],
|
||||
['abc123fff'],
|
||||
],
|
||||
'abc123*',
|
||||
[
|
||||
[1],
|
||||
[2],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
|
|
|||
Loading…
Reference in New Issue