string contains substring code example

Example 1: check if word is in string javascript

var str = "Hello world, welcome to the universe.";
var n = str.includes("world");

Example 2: javascript string contains function

s = "Hello world";
console.log(s.includes("world"));

Example 3: str.contains multiple strings

>>> searchfor = ['og', 'at']
>>> s[s.str.contains('|'.join(searchfor))]
0    cat
1    hat
2    dog
3    fog
dtype: object

Example 4: string contains in javascript

const string = "foo";
const substring = "oo";

console.log(string.includes(substring));

Example 5: check if string contains substring sql

Declare @mainString nvarchar(100)='Amit Kumar Yadav'  
---Check here @mainString contains Amit or not, if it contains then retrun greater than 0 then print Find otherwise Not Find  
if CHARINDEX('Amit',@mainString) > 0   
begin  
   select 'Find' As Result  
end  
else  
    select 'Not Find' As Result

Example 6: angular string contains

var string = "foo";
var substring = "oo";

console.log(string.indexOf(substring) !== -1);