StrIndexNc

Searches a string for a sub-string, ignoring case.

Syntax:

StrIndexNc (string, sub-string, start, direction)

Parameters:

(s) string the string to be searched for a sub-string.

(s) sub-string the string to look for within the main string.

(i) start the position in the main string to begin search. The first character of a string is position 1.

(i) direction the search direction. @FWDSCAN searches forward, while @BACKSCAN searches backwards.

Returns:

(i) position of sub-string within string, or 0 if not found.

 

This function searches for a sub-string within a "target" string. Starting at the "start" position, it goes forward or backward depending on the value of the "direction" parameter. It stops when it finds the "sub-string" within the "target" string, and returns its position. It is not case-sensitive.

A start position of 0 has special meaning depending on which direction you are scanning. For forward searches, zero indicates the search should start at the beginning of the string. For reverse searches, zero causes it to start at the end of the string.

If the sub-string is a blank (NULL) string and the specified start position is ZERO, this function returns the start position of the string for an @FWDSCAN search and the position of the last item for a @BACKSCAN search.

If both the string and the sub-string are blank (NULL) strings this function returns zero.

The StrIndexNC search is case insensitive. For a case sensitive search use StrIndex.

Example:


instr = AskLine("STRINDEX", "Type a sentence:", "", 0)
start = 1
daend = StrIndexNC(instr, " ", start, @FWDSCAN)
If daend == 0
   Message("Sorry...", "No spaces found")
Else
   a = StrCat("First word is: ", StrSub(instr,  start, daend - 1))
   Message("STRINDEX", a)
EndIf
See Also:

StrInsert, StrLen, StrOverlay, StrScan, StrSub, StrIndex, StrIndexWild