I'm using a webcrawler i made to fetch some data, and sometimes i need to check if a string contains another. The current method i'm using for it is 'includes' like this:
if(biggerString.includes(string){
//do my thing
}
But sometimes it doesn't work. Here's an example:
Bigger string: 'iphone 6 apple com 16gb tela 47” ios 8 touch id câmera isight 8mp wi-fi 3g4g gps mp3 bluetooth e nfc - cinza espacial'
Substring: 'iphone 6'
I tried to remove any special characters that could interfere like this:
let biggerString2 = biggerString.replace(/[&\/\\#,()$~%.'":*?<>{}]/g, '').trim().toLowerCase();
let substring2 = substring.replace(/[&\/\\#,()$~%.'":*?<>{}]/g, '').trim().toLowerCase();
But it still doesn't work. What am i missing here?