javascript regexp match code example
Example 1: match regex
const regex = /([a-z]*)ball/g;
const str = "basketball football baseball";
let result;
while((result = regex.exec(str)) !== null) {
console.log(result[1]);
// => basket
// => foot
// => base
}
Example 2: regex exact match
use ^ and $ to match the start and end of your string
^matchmeexactly$