Skip to content

Modern String StartsWith

Paul Squires edited this page Nov 8, 2026 · 6 revisions

Home › String Library › String Library › StartsWith

StartsWith

Returns true if the string begins with the given text.

Syntax

StartsWith( s, prefix [, ic] )

Notes

  • Overloads for slices take const slice, uslice or wslice arguments and copy nothing: StartsWith( v[0 to 9], "x" ). A string argument still gets the string overload.
  • O(m) — boolean

Examples

#import "std/strings"
using strings

print StartsWith( "Hello", "He" )         '' true
print StartsWith( "Hello", "he" )         '' false -- case matters by default
print StartsWith( "Hello", "he", true )   '' true
print StartsWith( "Hello", "" )           '' true -- every string starts with ""

Library: String Library
Category: String Library
Documented under: The Functions

Clone this wiki locally