Write Your JavaScript Code Here

// match(): method is used to match the string against a regular expression. We can use global search modifier with match() method to get all the match elements otherwise the method return only first match. // string.match(regexp) // search for a regular expression using global flag. let srt="Megatron" console.log(srt.match(/Mega/g)); // We can ignore case-sensitive behaviour of match() method by using ignore flag. Let's understand with the help of example: console.log(srt.match(/mega/gi));

Output: