Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

This question already has an answer here:

How can I check if a string contains another string instead of using "==" to compare the whole string?

Regards

share|improve this question
add comment (requires an account with 50 reputation)

marked as duplicate by Bergi, Andrew Whitaker, isedev, Luca Geretti, chepner Mar 23 at 17:34

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer

up vote 3 down vote accepted

You can use .indexOf():

if(str.indexOf(substr) > -1) {

}
share|improve this answer
didn't work when I use msgCache[id].headers.subject.indexOf("DELIVERY FAILURE:") > -1 – donald May 24 '11 at 10:12
and the subject is: DELIVERY FAILURE: User fdfd.ablfdfitt ([email protected]) not listed in Domino Directory – donald May 24 '11 at 10:13
Well, what is msgCache[id].headers.subject? – Felix Kling May 24 '11 at 10:13
it returns "DELIVERY FAILURE: User fdfd.ablfdfitt ([email protected]) not listed in Domino Directory" – donald May 24 '11 at 10:14
@donald: Works for me: jsfiddle.net/bZUvp (and it also works with node.js, it's the same JavaScript) – Felix Kling May 24 '11 at 10:14
show 1 more commentadd comment (requires an account with 50 reputation)

Not the answer you're looking for? Browse other questions tagged or ask your own question.