|
1 | 1 | # match builtin
|
2 | 2 | [match("( )*"; "g")]
|
3 | 3 | "abc"
|
4 |
| -[{"offset":0,"length":0,"string":"","captures":[{"offset":0,"string":"","length":0,"name":null}]},{"offset":1,"length":0,"string":"","captures":[{"offset":1,"string":"","length":0,"name":null}]},{"offset":2,"length":0,"string":"","captures":[{"offset":2,"string":"","length":0,"name":null}]},{"offset":3,"length":0,"string":"","captures":[{"offset":3,"string":"","length":0,"name":null}]}] |
| 4 | +[{"offset":0,"length":0,"string":"","captures":[{"offset":-1,"string":null,"length":0,"name":null}]},{"offset":1,"length":0,"string":"","captures":[{"offset":-1,"string":null,"length":0,"name":null}]},{"offset":2,"length":0,"string":"","captures":[{"offset":-1,"string":null,"length":0,"name":null}]},{"offset":3,"length":0,"string":"","captures":[{"offset":-1,"string":null,"length":0,"name":null}]}] |
5 | 5 |
|
6 | 6 | [match("( )*"; "gn")]
|
7 | 7 | "abc"
|
|
37 | 37 | "foo bar foo foo foo"
|
38 | 38 | [{"offset": 0, "length": 11, "string": "foo bar foo", "captures":[{"offset": 4, "length": 3, "string": "bar", "name": "bar123"}]},{"offset":12, "length": 8, "string": "foo foo", "captures":[{"offset": -1, "length": 0, "string": null, "name": "bar123"}]}]
|
39 | 39 |
|
| 40 | +# non-matched optional group |
| 41 | +"a","b","c" | capture("(?<x>a)?b?") |
| 42 | +null |
| 43 | +{"x":"a"} |
| 44 | +{"x":null} |
| 45 | +{"x":null} |
| 46 | + |
| 47 | +"a","b","c" | match("(?<x>a)?b?") |
| 48 | +null |
| 49 | +{"offset":0,"length":1,"string":"a","captures":[{"offset":0,"length":1,"string":"a","name":"x"}]} |
| 50 | +{"offset":0,"length":1,"string":"b","captures":[{"offset":-1,"string":null,"length":0,"name":"x"}]} |
| 51 | +{"offset":0,"length":0,"string":"","captures":[{"offset":-1,"string":null,"length":0,"name":"x"}]} |
| 52 | + |
| 53 | +# same as above but allow empty match for group |
| 54 | +"a","b","c" | capture("(?<x>a?)?b?") |
| 55 | +null |
| 56 | +{"x":"a"} |
| 57 | +{"x":""} |
| 58 | +{"x":""} |
| 59 | + |
| 60 | +"a","b","c" | match("(?<x>a?)?b?") |
| 61 | +null |
| 62 | +{"offset":0,"length":1,"string":"a","captures":[{"offset":0,"length":1,"string":"a","name":"x"}]} |
| 63 | +{"offset":0,"length":1,"string":"b","captures":[{"offset":0,"string":"","length":0,"name":"x"}]} |
| 64 | +{"offset":0,"length":0,"string":"","captures":[{"offset":0,"string":"","length":0,"name":"x"}]} |
| 65 | + |
40 | 66 | #test builtin
|
41 | 67 | [test("( )*"; "gn")]
|
42 | 68 | "abc"
|
|
0 commit comments