62
rated 0 times
[
69]
[
7]
/ answers: 1 / hits: 5950
/ 10 Years ago, wed, september 10, 2014, 12:00:00
I've been using the .indexOf('') > -1
in order to check whether there's a match in a string. The problem that I'm having is that when I'm performing the match on multiple strings, I get a match on the string for both EIFT and EI (since EIFT contains EI), and so the function returns true
for both sentences. What I need is a way for this to only return true for function eIft
if the string is EIFT, but not for EI
.
My current code is as follows, and I've been trying to think of ways around this but haven't had any success yet.
function eI(mystring){
return mystring.indexOf(EI) > -1
}
function eIft(mystring){
return mystring.indexOf(EIFT) > -1
}
Thanks!
More From » string-matching