You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+110Lines changed: 110 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -558,6 +558,116 @@ indexOf(x, a) | Return the first index of string or array `a` matching the value
558
558
join(sep, a) | Concatenate the elements of `a`, separated by `sep`.
559
559
if(c, a, b) | Function form of c ? a : b. Note: This always evaluates both `a` and `b`, regardless of whether `c` is `true` or not. Use `c ? a : b` instead if there are side effects, or if evaluating the branches could be expensive.
560
560
561
+
#### String Manipulation Functions
562
+
563
+
The parser includes comprehensive string manipulation capabilities:
564
+
565
+
**String Inspection**
566
+
567
+
Function | Description
568
+
:--------------------- | :----------
569
+
length(str) | Returns the length of a string. Also works as unary operator for numbers.
570
+
isEmpty(str) | Returns `true` if the string is empty (length === 0), `false` otherwise.
startsWith(str, substr)| Returns `true` if `str` starts with `substr`, `false` otherwise.
573
+
endsWith(str, substr) | Returns `true` if `str` ends with `substr`, `false` otherwise.
574
+
searchCount(str, substr)| Returns the count of non-overlapping occurrences of `substr` in `str`.
575
+
576
+
**String Transformation**
577
+
578
+
Function | Description
579
+
:--------------- | :----------
580
+
trim(str) | Removes whitespace from both ends of a string.
581
+
toUpper(str) | Converts a string to uppercase.
582
+
toLower(str) | Converts a string to lowercase.
583
+
toTitle(str) | Converts a string to title case (capitalizes first letter of each word).
584
+
repeat(str, n) | Repeats a string `n` times. `n` must be a non-negative integer.
585
+
reverse(str) | Reverses a string.
586
+
587
+
**String Extraction**
588
+
589
+
Function | Description
590
+
:--------------- | :----------
591
+
left(str, n) | Returns the leftmost `n` characters from a string.
592
+
right(str, n) | Returns the rightmost `n` characters from a string.
593
+
split(str, delim)| Splits a string by delimiter and returns an array.
594
+
595
+
**String Manipulation**
596
+
597
+
Function | Description
598
+
:-------------------------- | :----------
599
+
replace(str, old, new) | Replaces all occurrences of `old` with `new` in `str`.
600
+
replaceFirst(str, old, new) | Replaces only the first occurrence of `old` with `new` in `str`.
601
+
602
+
**String/Array Sorting**
603
+
604
+
Function | Description
605
+
:--------------- | :----------
606
+
naturalSort(arr) | Sorts an array of strings using natural sort order (alphanumeric-aware). For example, `["file10", "file2", "file1"]` becomes `["file1", "file2", "file10"]`.
607
+
608
+
**Type Conversion**
609
+
610
+
Function | Description
611
+
:--------------- | :----------
612
+
toNumber(str) | Converts a string to a number. Throws an error if the string cannot be converted.
613
+
toBoolean(str) | Converts a string to a boolean. Recognizes `"true"`, `"1"`, `"yes"`, `"on"` as `true` (case-insensitive), and `"false"`, `"0"`, `"no"`, `"off"`, `""` as `false`.
614
+
615
+
**String Padding**
616
+
617
+
Function | Description
618
+
:-------------------- | :----------
619
+
padLeft(str, len) | Pads a string on the left with spaces to reach the target length.
620
+
padRight(str, len) | Pads a string on the right with spaces to reach the target length.
0 commit comments