@rootMay 22.2016 — #and you can use a regular expression
<i> </i>s = "man"; console.log( "--------------------------------------------" ); console.log( s + " with no express conditions or rules"); str1 = "The old man is fishing all day"; str2 = "The old woman is gutting fish all day"; var reg = /man/; s1 = "> "+ s +" is "+ (reg.test(str1)?"":"not ") +"in "+str1; s2 = "> "+ s +" is "+ (reg.test(str2)?"":"not ") +"in "+str2; console.log(s1); console.log(s2); console.log( "--------------------------------------------" ); console.log( s + " with word boundaries"); var reg = /bmanb/; s1 = "> "+ s +" is "+ (reg.test(str1)?"":"not ") +"in "+str1; s2 = "> "+ s +" is "+ (reg.test(str2)?"":"not ") +"in "+str2; console.log(s1); console.log(s2); console.log( "--------------------------------------------" ); s = "Man"; console.log( s + " as case insensitive without word boundaries"); var reg = /Man/i; // case insensitive s1 = "> "+ s +" is "+ (reg.test(str1)?"":"not ") +"in "+str1; s2 = "> "+ s +" is "+ (reg.test(str2)?"":"not ") +"in "+str2; console.log(s1); console.log(s2); console.log( "--------------------------------------------" ); console.log( s + " as case insensitive with word boundaries"); var reg = /bManb/i; // case insensitive with word boundaries s1 = "> "+ s +" is "+ (reg.test(str1)?"":"not ") +"in "+str1; s2 = "> "+ s +" is "+ (reg.test(str2)?"":"not ") +"in "+str2; console.log(s1); console.log(s2); console.log( "--------------------------------------------" );
outputs the following -------------------------------------------- man with no express conditions or rules <i>> </i>man is in The old man is fishing all day <i>> </i>man is in The old woman is gutting fish all day ------------------------------------------- man with word boundaries <i>> </i>man is in The old man is fishing all day <i>> </i>man is not in The old woman is gutting fish all day -------------------------------------------- Man as case insensitive without word boundaries <i>> </i>Man is in The old man is fishing all day <i>> </i>Man is in The old woman is gutting fish all day -------------------------------------------- Man as case insensitive with word boundaries <i>> </i>Man is in The old man is fishing all day <i>> </i>Man is not in The old woman is gutting fish all day --------------------------------------------
F12 opens the console.log where the output goes to...
Regular Expressions are allot more powerful but can cause headaches.