rm index and indexof

This commit is contained in:
2026-01-17 16:21:02 -06:00
parent 97ece8e5cb
commit a7a323a74e
19 changed files with 86 additions and 303 deletions

View File

@@ -270,7 +270,7 @@ Cell supports regex patterns in string functions, but not standalone regex objec
```javascript
text.search("hello world", /world/)
text.replace("hello", /l/g, "L")
replace("hello", /l/g, "L")
```
## Error Handling

View File

@@ -70,18 +70,18 @@ text.search("hello world", "xyz") // null
text.search("hello hello", "hello", 1) // 6
```
### text.replace(text, target, replacement, limit)
### text.replace(text, target, replacement, cap)
Replace occurrences of `target` with `replacement`.
Replace occurrences of `target` with `replacement`. If `cap` is not specified, replaces all occurrences.
```javascript
text.replace("hello", "l", "L") // "heLLo"
text.replace("hello", "l", "L", 1) // "heLlo"
text.replace("hello", "l", "L") // "heLLo" (replaces all)
text.replace("hello", "l", "L", 1) // "heLlo" (replaces first only)
// With function
text.replace("hello", "l", function(match, pos) {
return pos == 2 ? "L" : match
}) // "heLlo"
}) // "heLLo" (replaces all by default)
```
### text.format(text, collection, transformer)