محتوى الدورة
Learn JavaScript in Arabic 2021
وصف الدرس

ال Code

/*
  Regular Expression
  Character Classes
  b => matches at the beginning or end of a word.
  B => matches NOT at the beginning/end of a word.

  Test Method
  pattern.test(input)
*/

let names = "Sayed 1Spam 2Spam 3Spam Spam4 Spam5 Osama Ahmed Aspamo";
let re = /(bspam|spamb)/ig;
console.log(names.match(re));

console.log(re.test(names));
console.log(/(bspam|spamb)/ig.test("Osama"));
console.log(/(bspam|spamb)/ig.test("1Spam"));
console.log(/(bspam|spamb)/ig.test("Spam1"));