Strings¶
Strings in RuLA represent text values. They are enclosed in double quotes.
Creating Strings¶
Create a string by enclosing text in double quotes:
An empty string ("") is valid and represents a string with no characters.
String Manipulation¶
Concatenation¶
Join strings together using + or CONCAT:
"Hello" + " " + "World" # Results in "Hello World"
CONCAT("Hello", " World") # Results in "Hello World"
Accessing Characters¶
Access individual characters by index (0-based):
Slicing¶
Extract a portion of a string:
SLICE("Hello World", 0, 5) # Returns "Hello"
LEFT("Hello World", 5) # Returns "Hello"
RIGHT("Hello World", 5) # Returns "World"
Case Conversion¶
Trimming Whitespace¶
Useful String Functions¶
| Function | Description | Example |
|---|---|---|
LEN |
Returns the number of characters | LEN("abc") â 3 |
CONCAT |
Joins multiple strings | CONCAT("a", "b") â "ab" |
LOWER |
Converts to lowercase | LOWER("ABC") â "abc" |
UPPER |
Converts to uppercase | UPPER("abc") â "ABC" |
TRIM |
Removes whitespace from both ends | TRIM(" a ") â "a" |
LEFT |
First n characters | LEFT("hello", 2) â "he" |
RIGHT |
Last n characters | RIGHT("hello", 2) â "lo" |
SLICE |
Extract substring | SLICE("hello", 1, 3) â "el" |
REPLACE |
Replace occurrences | REPLACE("a-b", "-", "/") â "a/b" |
SPLIT |
Split into list | SPLIT("a,b", ",") â ["a", "b"] |
STARTS_WITH |
Check prefix | STARTS_WITH("abc", "ab") â True |
ENDS_WITH |
Check suffix | ENDS_WITH("abc", "bc") â True |
JOIN |
Join list into string | JOIN(["a", "b"], "-") â "a-b" |
FORMAT_NUMBER |
Format as string | FORMAT_NUMBER(3.14159, 2) â "3.14" |
LEVENSHTEIN |
Edit distance | LEVENSHTEIN("kitten", "sitting") â 3 |
PAD_LEFT |
Pad on left | PAD_LEFT("5", 3, "0") â "005" |
PAD_RIGHT |
Pad on right | PAD_RIGHT("5", 3, "0") â "500" |
TRIM_LEFT |
Removes whitespace from start | TRIM_LEFT(" hello") â "hello" |
String Comparison¶
Compare strings using standard operators: