Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable support for wildcard text searches in Excel Database functions (…
…#1876) * Enable support for wildcard text searches in Excel Database functions
- Loading branch information
Mark Baker
committed
Feb 23, 2021
1 parent
40a6dee
commit 25f7dcb
Showing
6 changed files
with
95 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace PhpOffice\PhpSpreadsheet\Calculation\Internal; | ||
|
||
class MakeMatrix | ||
{ | ||
public static function make(...$args): array | ||
{ | ||
return $args; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace PhpOffice\PhpSpreadsheet\Calculation\Internal; | ||
|
||
class WildcardMatch | ||
{ | ||
private const SEARCH_SET = [ | ||
'/([^~])(\*)/ui', | ||
'/~\*/ui', | ||
'/([^~])(\?)/ui', | ||
'/~\?/ui', | ||
]; | ||
|
||
private const REPLACEMENT_SET = [ | ||
'${1}.*', | ||
'\*', | ||
'${1}.', | ||
'\?', | ||
]; | ||
|
||
public static function wildcard(string $wildcard): string | ||
{ | ||
return preg_replace(self::SEARCH_SET, self::REPLACEMENT_SET, $wildcard); | ||
} | ||
|
||
public static function compare($value, string $wildcard): bool | ||
{ | ||
if ($value === '') { | ||
return true; | ||
} | ||
|
||
return (bool) preg_match("/{$wildcard}/ui", $value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters