Answers for "JS glob to regex"

0

JS glob to regex

// Rudimentary code for matching globs with ? and *
// Escape the dots, change * to .* and ? to . 
// and make it match entire string
new RegExp
(
  '^' +
  rx.replaceAll('\.', '\\.')
  .replaceAll('*', '.*')
  .replaceAll('?', '.') +
  '$'
)
Posted by: Guest on September-21-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language