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 Parameter | Type | Description |
---|---|---|
text | string | The string to inspect. |
target | string | The string to search for. |
position (optional) | number | The position to search from. |
Return value
Type |
---|
boolean |
Sample
Example | Result | Description |
---|---|---|
startsWith('John', 'Jo') | true | Check if the string starts with the specific letter |
startsWith('John', 'Jo') | true | Check if a whether from given offset |
startsWith('abcd', 'ab') | true | Check if the text starts with 'ab' |
startsWith('abcd', 'b') | false | Check if the text starts with 'b' |
startsWith('abcd', 'b', 1) | true | Check if the text starts with 'b' from a given starting position |
To view all the String functions, click here.
See Also
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article