leponceau.org

Programming And Stuff, You Know The Thing…

Substring Search For Javascript

Posted at — Mar 7, 2013
if (test.indexOf("title") !=-1) {
    ...
}

// or...
if (test.match("title")) {
    ...
}

// or...
if("Watch out for the rock!".search(/for/) != -1) {
    ...
}