if (/A|B/.test(thingToTest)) { doSomething }
example:
var myString = "This is my search subject" if (/my/.test(myString)) { doSomethingHere }
This will look for "my" in the variable "myString". You can replace the string directly instead of the variable "myString".
As an added bonus, you can add to the search case insensitive "i" and global "g".
var myString = "This is my search subject" if (/my/ig.test(myString)) { doSomethingHere }
jgshawkey Mar 21 '19 at 12:31 on 2019-03-21 12:31
source share