Hi,
I would like to ask what is wrong with this script below. What I’m trying to achieve is search a particular word on a given string and make sure that the word is not misspelled by not having any additional letter or numbers at the beginning or end of the word (Special characters are allowed. Case sensitive search). What happens with this script is, it fails to search for the given word even if nothing is added before or after the word.
I have tried my RegEx on online testing tools and it actually works fine. If you guys know any alternative for my scenario please do let me know! Thank you very much.
let subcategoryName = currentSubcategoryRecord.name;
let keyword = new RegExp(`[^a-zA-Z0-9]${subcategoryName}[^a-zA-Z0-9]`);
isProductTypeExists = checkRecord.search(keyword);
if (isProductTypeExists == 0)
{
//Product exists!
}
// -1 is returned for no match found.
