Hello all,
I can’t understand how match() works.
I want to check if a substring is contained in a string, independently if the word has capital first letter or not. So I have this code:
var string = “Find my word”;
var w = “word”;
var substring = w;
var pattern = “/” + w + “/i”;
If I try:
string.match(substring); //This is working.
string.match(pattern); //This is not working and I got null.
Any idea why it’s not working as I expect?
Thank you!!