@grain/stdlib 0.6.6 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +67 -0
- package/LICENSE +1 -1
- package/README.md +2 -2
- package/array.gr +55 -7
- package/array.md +606 -560
- package/bigint.md +228 -228
- package/buffer.gr +85 -53
- package/buffer.md +442 -319
- package/bytes.gr +112 -35
- package/bytes.md +299 -219
- package/char.gr +201 -99
- package/char.md +447 -120
- package/exception.gr +11 -11
- package/exception.md +29 -4
- package/float32.gr +327 -3
- package/float32.md +698 -111
- package/float64.gr +320 -3
- package/float64.md +698 -111
- package/fs.gr +1082 -0
- package/fs.md +630 -0
- package/hash.gr +142 -88
- package/hash.md +105 -17
- package/int16.md +178 -178
- package/int32.gr +26 -5
- package/int32.md +266 -231
- package/int64.gr +27 -2
- package/int64.md +266 -231
- package/int8.md +178 -178
- package/json.gr +366 -51
- package/json.md +431 -15
- package/list.gr +328 -31
- package/list.md +759 -336
- package/map.gr +20 -12
- package/map.md +266 -260
- package/marshal.gr +41 -40
- package/marshal.md +14 -14
- package/number.gr +278 -35
- package/number.md +688 -269
- package/option.md +162 -162
- package/package.json +5 -3
- package/path.gr +48 -0
- package/path.md +180 -89
- package/pervasives.gr +2 -2
- package/pervasives.md +275 -275
- package/priorityqueue.gr +7 -7
- package/priorityqueue.md +131 -131
- package/queue.gr +183 -29
- package/queue.md +404 -148
- package/random.md +43 -43
- package/range.gr +4 -4
- package/range.md +42 -42
- package/rational.md +123 -123
- package/regex.gr +52 -51
- package/regex.md +102 -102
- package/result.md +118 -118
- package/runtime/atof/common.md +39 -39
- package/runtime/atof/decimal.gr +6 -6
- package/runtime/atof/decimal.md +14 -14
- package/runtime/atof/lemire.gr +5 -5
- package/runtime/atof/lemire.md +1 -1
- package/runtime/atof/parse.gr +16 -16
- package/runtime/atof/parse.md +2 -2
- package/runtime/atof/slow.md +1 -1
- package/runtime/atof/table.md +2 -2
- package/runtime/atoi/parse.gr +3 -3
- package/runtime/atoi/parse.md +1 -1
- package/runtime/bigint.gr +15 -47
- package/runtime/bigint.md +54 -60
- package/runtime/compare.gr +2 -2
- package/runtime/compare.md +8 -8
- package/runtime/dataStructures.md +211 -211
- package/runtime/debugPrint.gr +4 -1
- package/runtime/debugPrint.md +9 -9
- package/runtime/equal.gr +99 -77
- package/runtime/equal.md +8 -8
- package/runtime/exception.gr +62 -82
- package/runtime/exception.md +62 -11
- package/runtime/gc.gr +39 -45
- package/runtime/gc.md +4 -4
- package/runtime/malloc.gr +7 -7
- package/runtime/malloc.md +13 -13
- package/runtime/math/kernel/cos.gr +70 -0
- package/runtime/math/kernel/cos.md +14 -0
- package/runtime/math/kernel/sin.gr +65 -0
- package/runtime/math/kernel/sin.md +14 -0
- package/runtime/math/kernel/tan.gr +136 -0
- package/runtime/math/kernel/tan.md +14 -0
- package/runtime/math/rempio2.gr +244 -0
- package/runtime/math/rempio2.md +14 -0
- package/runtime/math/trig.gr +130 -0
- package/runtime/math/trig.md +28 -0
- package/runtime/math/umuldi.gr +26 -0
- package/runtime/math/umuldi.md +14 -0
- package/runtime/numberUtils.gr +29 -29
- package/runtime/numberUtils.md +12 -12
- package/runtime/numbers.gr +373 -381
- package/runtime/numbers.md +348 -342
- package/runtime/string.gr +37 -105
- package/runtime/string.md +20 -26
- package/runtime/unsafe/constants.md +24 -24
- package/runtime/unsafe/conv.md +19 -19
- package/runtime/unsafe/memory.gr +24 -20
- package/runtime/unsafe/memory.md +27 -7
- package/runtime/unsafe/offsets.gr +36 -0
- package/runtime/unsafe/offsets.md +88 -0
- package/runtime/unsafe/panic.gr +28 -0
- package/runtime/unsafe/panic.md +14 -0
- package/runtime/unsafe/tags.md +32 -32
- package/runtime/unsafe/wasmf32.md +28 -28
- package/runtime/unsafe/wasmf64.md +28 -28
- package/runtime/unsafe/wasmi32.md +47 -47
- package/runtime/unsafe/wasmi64.md +50 -50
- package/runtime/utf8.gr +189 -0
- package/runtime/utf8.md +117 -0
- package/runtime/wasi.gr +4 -2
- package/runtime/wasi.md +147 -147
- package/set.gr +18 -11
- package/set.md +253 -247
- package/stack.gr +171 -2
- package/stack.md +371 -89
- package/string.gr +352 -557
- package/string.md +298 -255
- package/uint16.md +170 -170
- package/uint32.gr +25 -4
- package/uint32.md +249 -214
- package/uint64.gr +25 -5
- package/uint64.md +249 -214
- package/uint8.md +170 -170
- package/uri.gr +57 -53
- package/uri.md +88 -89
- package/wasi/file.gr +67 -59
- package/wasi/file.md +308 -308
- package/wasi/process.md +26 -26
- package/wasi/random.md +12 -12
- package/wasi/time.md +16 -16
- package/runtime/utils/printing.gr +0 -60
- package/runtime/utils/printing.md +0 -26
package/regex.gr
CHANGED
|
@@ -118,11 +118,11 @@ let withConfig = (buf: RegExBuf, config: RegExParserConfig) => {
|
|
|
118
118
|
// Parsing internals for recursive descent
|
|
119
119
|
|
|
120
120
|
let parseErr = (buf: RegExBuf, msg: String, posShift) => {
|
|
121
|
-
"Invalid Regular Expression: "
|
|
122
|
-
msg
|
|
123
|
-
" (position "
|
|
124
|
-
toString(unbox(buf.cursor) + posShift)
|
|
125
|
-
")"
|
|
121
|
+
"Invalid Regular Expression: "
|
|
122
|
+
++ msg
|
|
123
|
+
++ " (position "
|
|
124
|
+
++ toString(unbox(buf.cursor) + posShift)
|
|
125
|
+
++ ")"
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
let next = (buf: RegExBuf) => {
|
|
@@ -167,11 +167,11 @@ let eat = (buf: RegExBuf, char: Char) => {
|
|
|
167
167
|
Err(
|
|
168
168
|
parseErr(
|
|
169
169
|
buf,
|
|
170
|
-
"Expected character '"
|
|
171
|
-
Char.toString(char)
|
|
172
|
-
", but found character '"
|
|
173
|
-
Char.toString(ret)
|
|
174
|
-
"'",
|
|
170
|
+
"Expected character '"
|
|
171
|
+
++ Char.toString(char)
|
|
172
|
+
++ ", but found character '"
|
|
173
|
+
++ Char.toString(ret)
|
|
174
|
+
++ "'",
|
|
175
175
|
0
|
|
176
176
|
),
|
|
177
177
|
)
|
|
@@ -244,8 +244,8 @@ and rangeUnion = (rng1, rng2) => {
|
|
|
244
244
|
match ((rng1, rng2)) {
|
|
245
245
|
([], _) => rng2,
|
|
246
246
|
(_, []) => rng1,
|
|
247
|
-
([(r1start, r1end), ...r1tl], [(r2start, r2end), ...r2tl]) when r1start
|
|
248
|
-
r2start => {
|
|
247
|
+
([(r1start, r1end), ...r1tl], [(r2start, r2end), ...r2tl]) when r1start
|
|
248
|
+
<= r2start => {
|
|
249
249
|
if (r1end + 1 >= r2start) {
|
|
250
250
|
if (r1end <= r2end) {
|
|
251
251
|
rangeUnion([(r1start, r2end), ...r2tl], r1tl)
|
|
@@ -687,8 +687,8 @@ and parsePosixCharClass = (buf: RegExBuf) => {
|
|
|
687
687
|
Ok(_) => Ok(List.join("", List.reverse(acc))),
|
|
688
688
|
}
|
|
689
689
|
},
|
|
690
|
-
Ok(c) when Char.code('a') <= Char.code(c)
|
|
691
|
-
Char.code(c) <= Char.code('z') => {
|
|
690
|
+
Ok(c) when Char.code('a') <= Char.code(c)
|
|
691
|
+
&& Char.code(c) <= Char.code('z') => {
|
|
692
692
|
ignore(eat(buf, c))
|
|
693
693
|
loop([Char.toString(c), ...acc])
|
|
694
694
|
},
|
|
@@ -857,9 +857,10 @@ and parseRangeRest = (
|
|
|
857
857
|
} else {
|
|
858
858
|
match (peek(buf)) {
|
|
859
859
|
Err(e) => Err(e),
|
|
860
|
-
Ok(c) when Char.code('a') <= Char.code(c)
|
|
861
|
-
Char.code(c) <= Char.code('z')
|
|
862
|
-
Char.code('A') <= Char.code(c)
|
|
860
|
+
Ok(c) when Char.code('a') <= Char.code(c)
|
|
861
|
+
&& Char.code(c) <= Char.code('z')
|
|
862
|
+
|| Char.code('A') <= Char.code(c)
|
|
863
|
+
&& Char.code(c) <= Char.code('Z') => {
|
|
863
864
|
match (mustSpanFrom) {
|
|
864
865
|
Some(_) =>
|
|
865
866
|
Err(
|
|
@@ -874,9 +875,9 @@ and parseRangeRest = (
|
|
|
874
875
|
match (parseClass(buf)) {
|
|
875
876
|
Err(e) =>
|
|
876
877
|
Err(
|
|
877
|
-
"Invalid Regular Expression: illegal alphebetic escape (position "
|
|
878
|
-
toString(curPos)
|
|
879
|
-
")",
|
|
878
|
+
"Invalid Regular Expression: illegal alphebetic escape (position "
|
|
879
|
+
++ toString(curPos)
|
|
880
|
+
++ ")",
|
|
880
881
|
),
|
|
881
882
|
Ok(range1) => {
|
|
882
883
|
match (rangeAddCaseAware(rng, spanFrom, buf.config)) {
|
|
@@ -1011,8 +1012,8 @@ let rec parseAtom = (buf: RegExBuf) => {
|
|
|
1011
1012
|
match (parseTest(buf)) {
|
|
1012
1013
|
Err(e) => Err(e),
|
|
1013
1014
|
Ok(test) => {
|
|
1014
|
-
let tstSpanNumGroups = unbox(buf.config.groupNumber)
|
|
1015
|
-
tstPreNumGroups
|
|
1015
|
+
let tstSpanNumGroups = unbox(buf.config.groupNumber)
|
|
1016
|
+
- tstPreNumGroups
|
|
1016
1017
|
match (parsePCEs(buf, false)) {
|
|
1017
1018
|
Err(e) => Err(e),
|
|
1018
1019
|
Ok(pces) => {
|
|
@@ -1252,8 +1253,8 @@ and parseTest = (buf: RegExBuf) => {
|
|
|
1252
1253
|
ignore(eat(buf, '?'))
|
|
1253
1254
|
parseLook(buf)
|
|
1254
1255
|
},
|
|
1255
|
-
Ok(c) when Char.code(c) >= Char.code('0')
|
|
1256
|
-
Char.code(c) <= Char.code('9') => {
|
|
1256
|
+
Ok(c) when Char.code(c) >= Char.code('0')
|
|
1257
|
+
&& Char.code(c) <= Char.code('9') => {
|
|
1257
1258
|
buf.config.references := true
|
|
1258
1259
|
let curPos = unbox(buf.cursor)
|
|
1259
1260
|
match (parseInteger(buf, 0)) {
|
|
@@ -1285,8 +1286,8 @@ and parseInteger = (buf: RegExBuf, n) => {
|
|
|
1285
1286
|
} else {
|
|
1286
1287
|
match (peek(buf)) {
|
|
1287
1288
|
Err(c) => Err(c),
|
|
1288
|
-
Ok(c) when Char.code(c) >= Char.code('0')
|
|
1289
|
-
Char.code(c) <= Char.code('9') => {
|
|
1289
|
+
Ok(c) when Char.code(c) >= Char.code('0')
|
|
1290
|
+
&& Char.code(c) <= Char.code('9') => {
|
|
1290
1291
|
ignore(next(buf))
|
|
1291
1292
|
parseInteger(buf, 10 * n + (Char.code(c) - Char.code('0')))
|
|
1292
1293
|
},
|
|
@@ -1503,11 +1504,11 @@ and parseUnicodeCategories = (buf: RegExBuf, pC: String) => {
|
|
|
1503
1504
|
Err(
|
|
1504
1505
|
parseErr(
|
|
1505
1506
|
buf,
|
|
1506
|
-
"Unrecognized property name in `\\"
|
|
1507
|
-
pC
|
|
1508
|
-
"`: `"
|
|
1509
|
-
s
|
|
1510
|
-
"`",
|
|
1507
|
+
"Unrecognized property name in `\\"
|
|
1508
|
+
++ pC
|
|
1509
|
+
++ "`: `"
|
|
1510
|
+
++ s
|
|
1511
|
+
++ "`",
|
|
1511
1512
|
0
|
|
1512
1513
|
),
|
|
1513
1514
|
),
|
|
@@ -1566,8 +1567,8 @@ and parseBackslashLiteral = (buf: RegExBuf) => {
|
|
|
1566
1567
|
match (peek(buf)) {
|
|
1567
1568
|
Err(e) => Err(e),
|
|
1568
1569
|
// pregexp:
|
|
1569
|
-
Ok(c) when buf.config.isPerlRegExp
|
|
1570
|
-
(Char.code(c) >= Char.code('0') && Char.code(c) <= Char.code('9')) => {
|
|
1570
|
+
Ok(c) when buf.config.isPerlRegExp
|
|
1571
|
+
&& (Char.code(c) >= Char.code('0') && Char.code(c) <= Char.code('9')) => {
|
|
1571
1572
|
buf.config.references := true
|
|
1572
1573
|
match (parseInteger(buf, 0)) {
|
|
1573
1574
|
Err(e) => Err(e),
|
|
@@ -1576,10 +1577,10 @@ and parseBackslashLiteral = (buf: RegExBuf) => {
|
|
|
1576
1577
|
},
|
|
1577
1578
|
}
|
|
1578
1579
|
},
|
|
1579
|
-
Ok(c) when buf.config.isPerlRegExp
|
|
1580
|
-
(
|
|
1581
|
-
Char.code(c) >= Char.code('a') && Char.code(c) <= Char.code('z')
|
|
1582
|
-
Char.code(c) >= Char.code('A') && Char.code(c) <= Char.code('Z')
|
|
1580
|
+
Ok(c) when buf.config.isPerlRegExp
|
|
1581
|
+
&& (
|
|
1582
|
+
Char.code(c) >= Char.code('a') && Char.code(c) <= Char.code('z')
|
|
1583
|
+
|| Char.code(c) >= Char.code('A') && Char.code(c) <= Char.code('Z')
|
|
1583
1584
|
) => {
|
|
1584
1585
|
match (c) {
|
|
1585
1586
|
'p' => {
|
|
@@ -2304,8 +2305,8 @@ let charMatcherIterated = (toMatch, max) =>
|
|
|
2304
2305
|
|
|
2305
2306
|
let subArraysEqual = (arr1, start1, arr2, start2, length) => {
|
|
2306
2307
|
if (
|
|
2307
|
-
Array.length(arr1) - start1 < length
|
|
2308
|
-
Array.length(arr2) - start2 < length
|
|
2308
|
+
Array.length(arr1) - start1 < length
|
|
2309
|
+
|| Array.length(arr2) - start2 < length
|
|
2309
2310
|
) {
|
|
2310
2311
|
return false
|
|
2311
2312
|
}
|
|
@@ -2328,8 +2329,8 @@ let stringMatcher = (toMatch, len, next_m) =>
|
|
|
2328
2329
|
stack,
|
|
2329
2330
|
) => {
|
|
2330
2331
|
if ({
|
|
2331
|
-
pos + len <= limit
|
|
2332
|
-
subArraysEqual(
|
|
2332
|
+
pos + len <= limit
|
|
2333
|
+
&& subArraysEqual(
|
|
2333
2334
|
buf.matchInputExploded,
|
|
2334
2335
|
pos,
|
|
2335
2336
|
String.explode(toMatch),
|
|
@@ -2350,8 +2351,8 @@ let stringTailMatcher = (toMatch, len) =>
|
|
|
2350
2351
|
stack,
|
|
2351
2352
|
) => {
|
|
2352
2353
|
if ({
|
|
2353
|
-
pos + len <= limit
|
|
2354
|
-
subArraysEqual(
|
|
2354
|
+
pos + len <= limit
|
|
2355
|
+
&& subArraysEqual(
|
|
2355
2356
|
buf.matchInputExploded,
|
|
2356
2357
|
pos,
|
|
2357
2358
|
String.explode(toMatch),
|
|
@@ -2584,8 +2585,8 @@ let isWordChar = c => {
|
|
|
2584
2585
|
|
|
2585
2586
|
let isWordBoundary = (buf, pos, start, limit, end) => {
|
|
2586
2587
|
!(
|
|
2587
|
-
(pos == start || !isWordChar(matchBufChar(buf, pos - 1)))
|
|
2588
|
-
(pos == end || !isWordChar(matchBufChar(buf, pos)))
|
|
2588
|
+
(pos == start || !isWordChar(matchBufChar(buf, pos - 1)))
|
|
2589
|
+
== (pos == end || !isWordChar(matchBufChar(buf, pos)))
|
|
2589
2590
|
)
|
|
2590
2591
|
}
|
|
2591
2592
|
|
|
@@ -2922,8 +2923,8 @@ let makeReferenceMatcher = eq =>
|
|
|
2922
2923
|
Some((refStart, refEnd)) => {
|
|
2923
2924
|
let len = refEnd - refStart
|
|
2924
2925
|
if (
|
|
2925
|
-
pos + len <= limit
|
|
2926
|
-
subArraysEqual(
|
|
2926
|
+
pos + len <= limit
|
|
2927
|
+
&& subArraysEqual(
|
|
2927
2928
|
buf.matchInputExploded,
|
|
2928
2929
|
refStart,
|
|
2929
2930
|
buf.matchInputExploded,
|
|
@@ -3448,8 +3449,8 @@ let checkMustString = (ms, buf: MatchBuf, pos, endPos) => {
|
|
|
3448
3449
|
None => true,
|
|
3449
3450
|
Some(ms) => {
|
|
3450
3451
|
let toCheck = if (
|
|
3451
|
-
pos == 0
|
|
3452
|
-
endPos == Array.length(buf.matchInputExploded)
|
|
3452
|
+
pos == 0
|
|
3453
|
+
&& endPos == Array.length(buf.matchInputExploded)
|
|
3453
3454
|
) {
|
|
3454
3455
|
buf.matchInput
|
|
3455
3456
|
} else {
|
|
@@ -3819,8 +3820,8 @@ let computeReplacement = (
|
|
|
3819
3820
|
} else {
|
|
3820
3821
|
let c = replacementExploded[pos]
|
|
3821
3822
|
if (
|
|
3822
|
-
Char.code('0') <= Char.code(c)
|
|
3823
|
-
Char.code(c) <= Char.code('9')
|
|
3823
|
+
Char.code('0') <= Char.code(c)
|
|
3824
|
+
&& Char.code(c) <= Char.code('9')
|
|
3824
3825
|
) {
|
|
3825
3826
|
dLoop(pos + 1, 10 * accum + (Char.code(c) - Char.code('0')))
|
|
3826
3827
|
} else {
|
package/regex.md
CHANGED
|
@@ -46,13 +46,13 @@ the following accessors:
|
|
|
46
46
|
|
|
47
47
|
Fields:
|
|
48
48
|
|
|
49
|
-
|name|type|description|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
| name | type | description |
|
|
50
|
+
| ------------------- | --------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
51
|
+
| `group` | `Number => Option<String>` | Returns the contents of the given group. Note that group 0 contains<br/>the entire matched substring, and group 1 contains the first parenthesized group. |
|
|
52
|
+
| `groupPosition` | `Number => Option<(Number, Number)>` | Returns the position of the given group |
|
|
53
|
+
| `numGroups` | `Number` | Returns the number of defined groups in this match object (includes group 0) |
|
|
54
|
+
| `allGroups` | `() => Array<Option<String>>` | Returns the contents of all groups matched in this match object |
|
|
55
|
+
| `allGroupPositions` | `() => Array<Option<(Number, Number)>>` | Returns the positions of all groups matched in this match object |
|
|
56
56
|
|
|
57
57
|
## Values
|
|
58
58
|
|
|
@@ -66,7 +66,7 @@ No other changes yet.
|
|
|
66
66
|
</details>
|
|
67
67
|
|
|
68
68
|
```grain
|
|
69
|
-
make
|
|
69
|
+
make: (regexString: String) => Result<RegularExpression, String>
|
|
70
70
|
```
|
|
71
71
|
|
|
72
72
|
Compiles the given pattern string into a regular expression object.
|
|
@@ -155,15 +155,15 @@ The *POSIX* classes are as follows:
|
|
|
155
155
|
|
|
156
156
|
Parameters:
|
|
157
157
|
|
|
158
|
-
|param|type|description|
|
|
159
|
-
|
|
160
|
-
|
|
158
|
+
| param | type | description |
|
|
159
|
+
| ------------- | -------- | --------------------------------- |
|
|
160
|
+
| `regexString` | `String` | The regular expression to compile |
|
|
161
161
|
|
|
162
162
|
Returns:
|
|
163
163
|
|
|
164
|
-
|type|description|
|
|
165
|
-
|
|
166
|
-
|
|
164
|
+
| type | description |
|
|
165
|
+
| ----------------------------------- | ------------------------------- |
|
|
166
|
+
| `Result<RegularExpression, String>` | The compiled regular expression |
|
|
167
167
|
|
|
168
168
|
Examples:
|
|
169
169
|
|
|
@@ -179,23 +179,23 @@ No other changes yet.
|
|
|
179
179
|
</details>
|
|
180
180
|
|
|
181
181
|
```grain
|
|
182
|
-
isMatch
|
|
182
|
+
isMatch: (rx: RegularExpression, string: String) => Bool
|
|
183
183
|
```
|
|
184
184
|
|
|
185
185
|
Determines if the given regular expression has a match in the given string.
|
|
186
186
|
|
|
187
187
|
Parameters:
|
|
188
188
|
|
|
189
|
-
|param|type|description|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
189
|
+
| param | type | description |
|
|
190
|
+
| -------- | ------------------- | ------------------------------------ |
|
|
191
|
+
| `rx` | `RegularExpression` | The regular expression to search for |
|
|
192
|
+
| `string` | `String` | The string to search within |
|
|
193
193
|
|
|
194
194
|
Returns:
|
|
195
195
|
|
|
196
|
-
|type|description|
|
|
197
|
-
|
|
198
|
-
|
|
196
|
+
| type | description |
|
|
197
|
+
| ------ | ------------------------------------------------------------ |
|
|
198
|
+
| `Bool` | `true` if the RegExp matches the string or `false` otherwise |
|
|
199
199
|
|
|
200
200
|
Examples:
|
|
201
201
|
|
|
@@ -211,7 +211,7 @@ No other changes yet.
|
|
|
211
211
|
</details>
|
|
212
212
|
|
|
213
213
|
```grain
|
|
214
|
-
isMatchRange
|
|
214
|
+
isMatchRange:
|
|
215
215
|
(rx: RegularExpression, string: String, start: Number, end: Number) => Bool
|
|
216
216
|
```
|
|
217
217
|
|
|
@@ -219,18 +219,18 @@ Determines if the given regular expression has a match in the given string betwe
|
|
|
219
219
|
|
|
220
220
|
Parameters:
|
|
221
221
|
|
|
222
|
-
|param|type|description|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
222
|
+
| param | type | description |
|
|
223
|
+
| -------- | ------------------- | ------------------------------------ |
|
|
224
|
+
| `rx` | `RegularExpression` | The regular expression to search for |
|
|
225
|
+
| `string` | `String` | The string to search |
|
|
226
|
+
| `start` | `Number` | The start offset to search between |
|
|
227
|
+
| `end` | `Number` | The end offset to search between |
|
|
228
228
|
|
|
229
229
|
Returns:
|
|
230
230
|
|
|
231
|
-
|type|description|
|
|
232
|
-
|
|
233
|
-
|
|
231
|
+
| type | description |
|
|
232
|
+
| ------ | ----------------------------------------------------------------------------- |
|
|
233
|
+
| `Bool` | `true` if the RegExp matches the string in the given range, otherwise `false` |
|
|
234
234
|
|
|
235
235
|
Examples:
|
|
236
236
|
|
|
@@ -250,23 +250,23 @@ No other changes yet.
|
|
|
250
250
|
</details>
|
|
251
251
|
|
|
252
252
|
```grain
|
|
253
|
-
find
|
|
253
|
+
find: (rx: RegularExpression, string: String) => Option<MatchResult>
|
|
254
254
|
```
|
|
255
255
|
|
|
256
256
|
Returns the first match for the given regular expression contained within the given string.
|
|
257
257
|
|
|
258
258
|
Parameters:
|
|
259
259
|
|
|
260
|
-
|param|type|description|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
260
|
+
| param | type | description |
|
|
261
|
+
| -------- | ------------------- | ------------------------------------ |
|
|
262
|
+
| `rx` | `RegularExpression` | The regular expression to search for |
|
|
263
|
+
| `string` | `String` | The string to search |
|
|
264
264
|
|
|
265
265
|
Returns:
|
|
266
266
|
|
|
267
|
-
|type|description|
|
|
268
|
-
|
|
269
|
-
|
|
267
|
+
| type | description |
|
|
268
|
+
| --------------------- | ------------------------ |
|
|
269
|
+
| `Option<MatchResult>` | The match result, if any |
|
|
270
270
|
|
|
271
271
|
Examples:
|
|
272
272
|
|
|
@@ -282,7 +282,7 @@ No other changes yet.
|
|
|
282
282
|
</details>
|
|
283
283
|
|
|
284
284
|
```grain
|
|
285
|
-
findRange
|
|
285
|
+
findRange:
|
|
286
286
|
(rx: RegularExpression, string: String, start: Number, end: Number) =>
|
|
287
287
|
Option<MatchResult>
|
|
288
288
|
```
|
|
@@ -292,18 +292,18 @@ between the given start/end range.
|
|
|
292
292
|
|
|
293
293
|
Parameters:
|
|
294
294
|
|
|
295
|
-
|param|type|description|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
295
|
+
| param | type | description |
|
|
296
|
+
| -------- | ------------------- | ------------------------------------ |
|
|
297
|
+
| `rx` | `RegularExpression` | The regular expression to search for |
|
|
298
|
+
| `string` | `String` | The string to search |
|
|
299
|
+
| `start` | `Number` | The start offset to search between |
|
|
300
|
+
| `end` | `Number` | The end offset to search between |
|
|
301
301
|
|
|
302
302
|
Returns:
|
|
303
303
|
|
|
304
|
-
|type|description|
|
|
305
|
-
|
|
306
|
-
|
|
304
|
+
| type | description |
|
|
305
|
+
| --------------------- | ------------------------ |
|
|
306
|
+
| `Option<MatchResult>` | The match result, if any |
|
|
307
307
|
|
|
308
308
|
Examples:
|
|
309
309
|
|
|
@@ -314,23 +314,23 @@ Regex.findRange(Result.unwrap(Regex.make("ca+[at]")), "caaat", 0, 5)
|
|
|
314
314
|
### Regex.**findAll**
|
|
315
315
|
|
|
316
316
|
```grain
|
|
317
|
-
findAll
|
|
317
|
+
findAll: (rx: RegularExpression, string: String) => List<MatchResult>
|
|
318
318
|
```
|
|
319
319
|
|
|
320
320
|
Returns all matches for the given regular expression contained within the given string.
|
|
321
321
|
|
|
322
322
|
Parameters:
|
|
323
323
|
|
|
324
|
-
|param|type|description|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
324
|
+
| param | type | description |
|
|
325
|
+
| -------- | ------------------- | ------------------------------------ |
|
|
326
|
+
| `rx` | `RegularExpression` | The regular expression to search for |
|
|
327
|
+
| `string` | `String` | The string to search |
|
|
328
328
|
|
|
329
329
|
Returns:
|
|
330
330
|
|
|
331
|
-
|type|description|
|
|
332
|
-
|
|
333
|
-
|
|
331
|
+
| type | description |
|
|
332
|
+
| ------------------- | ------------------- |
|
|
333
|
+
| `List<MatchResult>` | The list of matches |
|
|
334
334
|
|
|
335
335
|
### Regex.**findAllRange**
|
|
336
336
|
|
|
@@ -340,7 +340,7 @@ No other changes yet.
|
|
|
340
340
|
</details>
|
|
341
341
|
|
|
342
342
|
```grain
|
|
343
|
-
findAllRange
|
|
343
|
+
findAllRange:
|
|
344
344
|
(rx: RegularExpression, string: String, start: Number, end: Number) =>
|
|
345
345
|
List<MatchResult>
|
|
346
346
|
```
|
|
@@ -350,18 +350,18 @@ between the given start/end range.
|
|
|
350
350
|
|
|
351
351
|
Parameters:
|
|
352
352
|
|
|
353
|
-
|param|type|description|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
353
|
+
| param | type | description |
|
|
354
|
+
| -------- | ------------------- | ------------------------------------ |
|
|
355
|
+
| `rx` | `RegularExpression` | The regular expression to search for |
|
|
356
|
+
| `string` | `String` | The string to search |
|
|
357
|
+
| `start` | `Number` | The start offset to search between |
|
|
358
|
+
| `end` | `Number` | The end offset to search between |
|
|
359
359
|
|
|
360
360
|
Returns:
|
|
361
361
|
|
|
362
|
-
|type|description|
|
|
363
|
-
|
|
364
|
-
|
|
362
|
+
| type | description |
|
|
363
|
+
| ------------------- | ------------------- |
|
|
364
|
+
| `List<MatchResult>` | The list of matches |
|
|
365
365
|
|
|
366
366
|
Examples:
|
|
367
367
|
|
|
@@ -377,7 +377,7 @@ No other changes yet.
|
|
|
377
377
|
</details>
|
|
378
378
|
|
|
379
379
|
```grain
|
|
380
|
-
replace
|
|
380
|
+
replace:
|
|
381
381
|
(rx: RegularExpression, toSearch: String, replacement: String) => String
|
|
382
382
|
```
|
|
383
383
|
|
|
@@ -393,17 +393,17 @@ Replacement strings support the following syntax:
|
|
|
393
393
|
|
|
394
394
|
Parameters:
|
|
395
395
|
|
|
396
|
-
|param|type|description|
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
396
|
+
| param | type | description |
|
|
397
|
+
| ------------- | ------------------- | ------------------------------------ |
|
|
398
|
+
| `rx` | `RegularExpression` | The regular expression to search for |
|
|
399
|
+
| `toSearch` | `String` | The string to search |
|
|
400
|
+
| `replacement` | `String` | The string that replaces matches |
|
|
401
401
|
|
|
402
402
|
Returns:
|
|
403
403
|
|
|
404
|
-
|type|description|
|
|
405
|
-
|
|
406
|
-
|
|
404
|
+
| type | description |
|
|
405
|
+
| -------- | ---------------------------------------------------------- |
|
|
406
|
+
| `String` | The given string with the appropriate replacements, if any |
|
|
407
407
|
|
|
408
408
|
Examples:
|
|
409
409
|
|
|
@@ -419,7 +419,7 @@ No other changes yet.
|
|
|
419
419
|
</details>
|
|
420
420
|
|
|
421
421
|
```grain
|
|
422
|
-
replaceAll
|
|
422
|
+
replaceAll:
|
|
423
423
|
(rx: RegularExpression, toSearch: String, replacement: String) => String
|
|
424
424
|
```
|
|
425
425
|
|
|
@@ -428,17 +428,17 @@ See `replace` for replacement string syntax.
|
|
|
428
428
|
|
|
429
429
|
Parameters:
|
|
430
430
|
|
|
431
|
-
|param|type|description|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
431
|
+
| param | type | description |
|
|
432
|
+
| ------------- | ------------------- | ------------------------------------ |
|
|
433
|
+
| `rx` | `RegularExpression` | The regular expression to search for |
|
|
434
|
+
| `toSearch` | `String` | The string to search |
|
|
435
|
+
| `replacement` | `String` | The string that replaces matches |
|
|
436
436
|
|
|
437
437
|
Returns:
|
|
438
438
|
|
|
439
|
-
|type|description|
|
|
440
|
-
|
|
441
|
-
|
|
439
|
+
| type | description |
|
|
440
|
+
| -------- | ---------------------------------------------------------- |
|
|
441
|
+
| `String` | The input string with the appropriate replacements, if any |
|
|
442
442
|
|
|
443
443
|
Examples:
|
|
444
444
|
|
|
@@ -454,7 +454,7 @@ No other changes yet.
|
|
|
454
454
|
</details>
|
|
455
455
|
|
|
456
456
|
```grain
|
|
457
|
-
split
|
|
457
|
+
split: (rx: RegularExpression, str: String) => List<String>
|
|
458
458
|
```
|
|
459
459
|
|
|
460
460
|
Splits the given string at the first match for the given regular expression.
|
|
@@ -464,16 +464,16 @@ will be included in the output list.
|
|
|
464
464
|
|
|
465
465
|
Parameters:
|
|
466
466
|
|
|
467
|
-
|param|type|description|
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
467
|
+
| param | type | description |
|
|
468
|
+
| ----- | ------------------- | ------------------------------- |
|
|
469
|
+
| `rx` | `RegularExpression` | The regular expression to match |
|
|
470
|
+
| `str` | `String` | The string to split |
|
|
471
471
|
|
|
472
472
|
Returns:
|
|
473
473
|
|
|
474
|
-
|type|description|
|
|
475
|
-
|
|
476
|
-
|
|
474
|
+
| type | description |
|
|
475
|
+
| -------------- | ---------------------------- |
|
|
476
|
+
| `List<String>` | A list of the split segments |
|
|
477
477
|
|
|
478
478
|
Examples:
|
|
479
479
|
|
|
@@ -489,7 +489,7 @@ No other changes yet.
|
|
|
489
489
|
</details>
|
|
490
490
|
|
|
491
491
|
```grain
|
|
492
|
-
splitAll
|
|
492
|
+
splitAll: (rx: RegularExpression, str: String) => List<String>
|
|
493
493
|
```
|
|
494
494
|
|
|
495
495
|
Splits the given string at every match for the given regular expression.
|
|
@@ -499,16 +499,16 @@ will be included in the output list.
|
|
|
499
499
|
|
|
500
500
|
Parameters:
|
|
501
501
|
|
|
502
|
-
|param|type|description|
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
502
|
+
| param | type | description |
|
|
503
|
+
| ----- | ------------------- | ------------------------------- |
|
|
504
|
+
| `rx` | `RegularExpression` | The regular expression to match |
|
|
505
|
+
| `str` | `String` | The string to split |
|
|
506
506
|
|
|
507
507
|
Returns:
|
|
508
508
|
|
|
509
|
-
|type|description|
|
|
510
|
-
|
|
511
|
-
|
|
509
|
+
| type | description |
|
|
510
|
+
| -------------- | ---------------------------- |
|
|
511
|
+
| `List<String>` | A list of the split segments |
|
|
512
512
|
|
|
513
513
|
Examples:
|
|
514
514
|
|