Skip to content

StringUtils.indexOfIgnoreCase

Signature: StringUtils.indexOfIgnoreCase(inputString, searchString, startPosition*)

Returns: Integer index - the first index of the searchString ignoring the case, -1 if no match or null inputString

Finds the first index of searchString within the inputString, handling null ignoring the case. A null inputString will return -1. A negative startPosition is treated as zero. An empty ("") searchString always matches. A startPosition greater than the inputString length only matches an empty searchString.

Parameters

Type Name Description Default
String inputString the String to check, may be null
String searchString the String to find, may be null
Integer startPosition* (optional) the startPosition, negative treated as zero 0

Example

var simpleString = "I am trying to find the number that's making me numb!";
var firstIndexOfNUM = StringUtils.indexOfIgnoreCase(simpleString, "NUM");       // 24
var indexOfNUMAfter40 = StringUtils.indexOfIgnoreCase(simpleString, "nUm", 40); // 48