Created
May 5, 2022 18:52
-
-
Save alexcmgit/1abfc68c838f58b219bbcfb4167ba827 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/// Checks if [source] contains all the characters of [text] | |
/// in the correct order | |
/// | |
/// Example: | |
/// ``` | |
/// hasMatch('abcdef', 'adf') // true | |
/// hasMatch('dbcaef', 'adf') // false | |
/// ``` | |
bool hasWildcardMatch(String source, String text) { | |
final regexp = text.split('').join('.*'); | |
return RegExp(regexp).hasMatch(source); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment