To search only for a fixed value in a string I can use the JavaScript function indexOf()
, example:
var string = "Oberyn se vinga";
string.indexOf('vinga') >= 0 //retorna true ou false
But how would I do to check multiple values against a string? Example:
var string = "Oberyn se vinga de Sor Clegane";
string.indexOf(['vinga','de','Clegane'])
Apparently the indexOf()
function does not accept arrays in the search.
The only way would be to use regex ? Or is there any specific function for these cases?