Skip to content

Instantly share code, notes, and snippets.

@alexcmgit
Created May 5, 2022 18:52
Show Gist options
  • Save alexcmgit/1abfc68c838f58b219bbcfb4167ba827 to your computer and use it in GitHub Desktop.
Save alexcmgit/1abfc68c838f58b219bbcfb4167ba827 to your computer and use it in GitHub Desktop.
/// 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