Skip to content

Instantly share code, notes, and snippets.

@ahmehri
Created May 27, 2018 16:49
Show Gist options
  • Save ahmehri/eed47cf9a1d67f23eeca318647db083f to your computer and use it in GitHub Desktop.
Save ahmehri/eed47cf9a1d67f23eeca318647db083f to your computer and use it in GitHub Desktop.
const msg = 'test';
const test1 = 'test1';
const regex = /test/;
console.log(regex.test(msg));
const regex1 = `/${msg}/`;
// console.log(regex1.test(msg)) // regex1.test is not a function
const regex3 = /`${msg}$`/
regex3
console.log(regex3.test(msg))
const regex2 = RegExp(`${msg}$`);
regex2
console.log(regex2.test(msg));
console.log(regex2.test(test1));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment