We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 42b28e6 commit eeea3dfCopy full SHA for eeea3df
1 file changed
src/Libraries/Core/StringProcessor.php
@@ -4,6 +4,20 @@
4
5
class StringProcessor
6
{
7
+ /**
8
+ * Matches a pattern to a fuzzy subject, e.g. 'api.*' should match 'api.enabled'
9
+ *
10
+ * @param string $pattern The pattern that the subject should match, e.g. 'api.*'
11
+ * @param string $subject The subject that is being compared, e.g. 'api.enabled'
12
+ * @return boolean Whether the string matches.
13
+ */
14
+ public static function fuzzyMatch(string $pattern, string $subject): bool
15
+ {
16
+ $pattern = \preg_replace_callback('/([^*])/', 'preg_quote', $pattern);
17
+ $pattern = \str_replace('*', '.*', $pattern);
18
+ return (bool) \preg_match('/^' . $pattern . '$/i', $subject);
19
+ }
20
+
21
/**
22
* Checks whether the current User Agent is a GUI web browser known by a common string, e.g. Firefox.
23
*
0 commit comments