Skip to content

Instantly share code, notes, and snippets.

@alexcmgit
Created May 13, 2021 02:10
Show Gist options
  • Save alexcmgit/073630b6a7a2cf124b6b2a36796810ab to your computer and use it in GitHub Desktop.
Save alexcmgit/073630b6a7a2cf124b6b2a36796810ab 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