how to check string with regex in javascript code example

Example 1: javascript regex .test

const str = 'hello world!';
const result = /^hello/.test(str);

console.log(result); // true

/**
The test() method executes a search for a match between 
a regular expression and a specified string
*/

Example 2: js string to regex

const regex = new RegExp('https:\\/\\/\\w*\\.\\w*.*', 'g');

Example 3: javascript inbuilt funcctions to match the word and return boolean

String.prototype.isMatch = function(s){
   return this.match(s)!==null 
}

Example 4: js match true false

/match/.test('string match') // true