//The match() method searches a string for a match against a regular expression, and returns the matches, as an Array object.
// ex : Search a string for "ain":
let text = "The rain in SPAIN stays mainly in the plain";
text.match(/ain/g);
// >> ain,ain,ain
//if you find this answer is useful ,
//upvote ⇑⇑ , so can the others benefit also . @mohammad alshraideh ( ͡~ ͜ʖ ͡°)
let text = "The rain in SPAIN stays mainly in the plain";
text.match(/ain/g);