Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1 @@
def s: "一二三四五六七八九十";

View file

@ -0,0 +1 @@
def ix(s): explode | index(s|explode);

View file

@ -0,0 +1,20 @@
# starting from n characters in and of m length: .[n+1: n+m+1]
"s[1:2] => \( s[1:2] )",
# starting from n characters in, up to the end of the string: .[n+1:]
"s[9:] => \( s[9:] )",
# whole string minus last character: .[0:length-1]
"s|.[0:length-1] => \(s | .[0:length-1] )",
# starting from a known character within the string and of m length:
# jq 1.4: ix(c) as $i | .[ $i: $i + m]
# jq>1.4: match(c).offset as $i | .[ $i: $i + m]
"s | ix(\"五\") as $i | .[$i: $i + 1] => \(s | ix("五") as $i | .[$i: $i + 1] )",
# starting from a known substring within the string and of m length:
# jq 1.4: ix(sub) as $i | .[ $i: $i + m]
# jq>1.4: match(sub).offset as $i | .[ $i: $i + m]
"s | ix(\"五六\") as $i | .[$i: $i + 2] => " +
"\( s | ix("五六") as $i | .[$i: $i + 2] )"

View file

@ -0,0 +1,6 @@
$ jq -M -n -r -f Substring.jq
s[1:2] => 二
s[9:] => 十
s|.[0:length-1] => 一二三四五六七八九
s | ix("五") as $i | .[$i: $i + 1] => 五
s | ix("五六") as $i | .[$i: $i + 2] => 五六