$pos

From Scriptwiki
Jump to: navigation, search

Returns a number indicating the position of the Nth occurrence of string in text.

$pos(text,string,N)

If N is zero, it returns the number of times string appears in text.

Note: You can use $poscs() for a case-sensitive version.

Example

$pos(hello there,e,1)  returns 2
$pos(hello there,e,2)  returns 9
$pos(hello there,a,1)  returns $null

See Also

  • $mid - Returns part of a string given a starting point and length.
  • $count - Returns the number of times a substring occurs in string.
  • $str - Returns text repeated.