startsWith

Modified on Wed, 16 Aug 2023

Description

Check if string starts with the given target string

Syntax

starts_with(text, target, position)

Parameters

Input ParameterTypeDescription
textstringThe string to inspect.
targetstringThe string to search for.
position (optional)numberThe position to search from.

Return value

Type
boolean

Sample

ExampleResultDescription
startsWith('John', 'Jo')trueCheck if the string starts with the specific letter
startsWith('John', 'Jo')trueCheck if a whether from given offset
startsWith('abcd', 'ab')trueCheck if the text starts with 'ab'
startsWith('abcd', 'b')falseCheck if the text starts with 'b'
startsWith('abcd', 'b', 1)trueCheck if the text starts with 'b' from a given starting position

To view all the String functions, click here.

See Also