Skip to content

Instantly share code, notes, and snippets.

@nblackburn
Last active October 21, 2017 20:07
Show Gist options
  • Select an option

  • Save nblackburn/7bb4e7fa8f1ed5106ccc81c93308af0f to your computer and use it in GitHub Desktop.

Select an option

Save nblackburn/7bb4e7fa8f1ed5106ccc81c93308af0f to your computer and use it in GitHub Desktop.
Check if a string matches a wildcard pattern.
module.exports = (test, pattern) => {
return new RegExp(test.replace(/\*/g, '([^*]+)'), 'g').test(pattern);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment