-2

returns the index where pattern starts in string (or -1 if not found). The search is to be case sensitive if the 3rd parameter is true otherwise it is case insensitive.

Examples
index("abAB12","AB",true) returns 2 but index("abAB12","AB",false) returns 0
index("abAB12","BA",true) returns -1 and index("abAB12","BA",false) returns 1
Elliott Davidson
  • 209
  • 1
  • 5
  • 20

1 Answers1

1

Maybe something like:

var str = "abAB12";
var i = str.indexOf("AB");
if (i < str.length / 2) {
  //stuff
} else {
  //other stuff
}
  • the thing is I need to take the information out of the string not hard code it into it, if you get what I mean. – Elliott Davidson Nov 07 '13 at 06:58
  • @Elliott: This doesn't seem to match with your statement given in an other comment where you said "I want to see if the AB is in the first part of the string". You really should edit your question and describe your problem properly. Right now we are merely guessing. – Felix Kling Nov 07 '13 at 07:04