Dz
Djazair
v1.0.5
🔍

Strings

Djazair Strings are immutable, UTF-8 encoded, and packed with formatting, trimming, and searching APIs.

String Literals

Use double quotes for standard strings. Strings support variable interpolation using ${expression}:

let user = "Riyadh"
let greet = "Hello, ${user}! The time is ${getLine()}"
print(greet)

Multiline Strings

Use backticks (`) to construct multiline blocks. Interpolation operates inside backticks as well:

let val = 42
let query = `
    SELECT * 
    FROM users 
    WHERE id = ${val};
`
print(query)

String Methods

Method Description
length()Character count
upper()Uppercase conversion
lower()Lowercase conversion
strip()Trim whitespace from both ends
lStrip()Trim whitespace from left
rStrip()Trim whitespace from right
contains(substr)Check if substring exists
find(substr)Return index of substring (alias for index)
count(substr)Count occurrences of substring
index(needle)First index of needle (returns -1 if not found)
split(sep?)Split into array (default: whitespace)
join(list)Join array elements with this string as separator
slice(start, end?)Extract substring
subStr(start, length?)Extract by start and length
replace(old, new)Replace all occurrences
reverse()Reverse string in-place
reversed()Return reversed string copy
repeat(n)Return string repeated n times
zFill(width)Zero-pad to given width
center(width)Center string in field of given width
lJust(width)Left-justify in field of given width
rJust(width)Right-justify in field of given width
startsWith(prefix)Check if starts with prefix
endsWith(suffix)Check if ends with suffix
capitalize()First character uppercase, rest lowercase
title()Title case
swapCase()Swap uppercase/lowercase
charCodeAt(i)Character code at index
isAlpha()Check if all alphabetic
isAlnum()Check if all alphanumeric
isDigit()Check if all digits
isLower()Check if all lowercase
isUpper()Check if all uppercase
isSpace()Check if all whitespace
concat(...)Concatenate multiple strings

String Method Examples

let s = "  Hello World  "
print(s.length())          # => 15
print(s.strip())           # => "Hello World"
print(s.upper())           # => "  HELLO WORLD  "
print(s.contains("World")) # => True
print(s.replace("World", "Djazair")) # => "  Hello Djazair  "
print("a,b,c".split(","))  # => ["a", "b", "c"]
print(", ".join(["a", "b", "c"])) # => "a, b, c"
print("hello".index("l"))  # => 2
print("hello".index("x"))  # => -1 (not found)
print("42".zFill(5))       # => "00042"
© 2026 Harizi Riyadh. Released under the MIT License.
Official Website for Djazair.