.match regex code example
Example 1: js match any number string
const match = 'some/path/123'.match(/\/(\d+)/)
const id = match[1] // '123'
Example 2: 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 3: regex exact match
use ^ and $ to match the start and end of your string
^matchmeexactly$