NInStr

Count = NInStr ( String AS String , Substring AS String [ , Comparison AS Integer ] )

Since 3.21

Returns the number of occurrences of a substring.

Arguments

  • String : The string to look into.

  • Substring: The substring to search.

  • Comparison: The comparison algorithm to use.

Return value

Return the number of occurrences, or zero if no occurrence is found.

Description

This function returns the number of occurrences of Substring inside String.

Comparison can be one of the following value: If Comparison is not specified, then a binary comparison is done.

This function only deals with ASCII strings. To manipulate UTF-8 strings, use the String class.

Examples

PRINT NInstr("Gambas Almost Means BASIC", "a")
3

PRINT NInstr("Gambas Almost Means BASIC", "A")
2

PRINT NInstr("Gambas Almost Means BASIC", "a", gb.IgnoreCase)
5

PRINT NInstr("Gambas Almost Means BASIC", "Bas", gb.IgnoreCase)
2

See also