String.search

String.search

String.search

Function

Finds the first occurrence of a string or regular expression in the current string.

Syntax

Parameters

ParametersTypeRequiredDefault valueDescription
patternString/RegexNo''The string or regular expression to find.

Return value

TypeDescription
IntReturns the starting byte position if found; returns -1 if not found.

Example

Notes

  • The return value is calculated as a UTF-8 byte offset.