starts_with

Modified on Thu, 9 Jul at 10:49 AM

starts_with

TABLE OF CONTENTS

Check if a function starts with a given prefix

Definition

boolean starts_with(string $text, string $prefix)

Checks if $text starts with $prefix. Case-sensitive.

Parameters

string $text

The string to check the start of.

string $suffix

The prefix for which the string is checked.

Returns

boolean

true if $text starts with $prefix, otherwise false.

Examples

Transformation
{
    a: starts_with('Create Classic', 'Cre'),
    b: starts_with('Create Classic', 'C'),
    c: starts_with('Create Classic', 'c'),
    d: starts_with('Create Classic', 'ate'),
    e: starts_with(`123`,`1`),
    f: starts_with(`123`,`2`),
    g: starts_with(`{"a": 1}`,`"a"`)
}
Result
{
  "a": true,
  "b": true,
  "c": false,
  "d": false,
  "e": true,
  "f": false,
}

Remarks

Designed for strings, but works for numbers as well.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article