For the complete documentation index, see llms.txt. This page is also available as Markdown.

Searching & Testing

Methods that inspect a string's contents. Positions are 1-indexed; "not found" is 0.

.contains(substr)boolean

Whether the string contains substr.

.containsAny(...subs)boolean

Whether the string contains any one of the given substrings.

.startsWith(prefix)boolean

Whether the string begins with prefix.

.endsWith(suffix)boolean

Whether the string ends with suffix.

log "report.csv".endsWith(".csv")  // true
log "abc".containsAny("x", "b")    // true

.index(substr)number

Position of the first occurrence of substr (1-indexed), or 0 if absent.

.lastIndex(substr)number

Position of the last occurrence (1-indexed), or 0 if absent.

.count(substr)number

Number of times substr appears.

Last updated