startswith

string

Checks if a string starts with a specific prefix

Syntax

startswith(string, prefix)

Parameters

string (string)

The string to check

prefix (string)

The prefix to look for

Returns

boolean

True if string starts with prefix, false otherwise

Examples

Input:
startswith("/api/users", "/api")
Output:
true
Input:
startswith("hello", "hi")
Output:
false
Input:
"test.txt" | startswith("test")
Output:
true

The startswith() function checks whether a string begins with a specified prefix. Returns true if it does, false otherwise.

Usage

Use startswith() to filter paths, validate formats, or check string patterns. Useful for routing, file extension checking, and protocol validation.

Related Functions