September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
1
Task/Substring/Jq/substring-1.jq
Normal file
1
Task/Substring/Jq/substring-1.jq
Normal file
|
|
@ -0,0 +1 @@
|
|||
def s: "一二三四五六七八九十";
|
||||
1
Task/Substring/Jq/substring-2.jq
Normal file
1
Task/Substring/Jq/substring-2.jq
Normal file
|
|
@ -0,0 +1 @@
|
|||
def ix(s): explode | index(s|explode);
|
||||
20
Task/Substring/Jq/substring-3.jq
Normal file
20
Task/Substring/Jq/substring-3.jq
Normal 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] )"
|
||||
6
Task/Substring/Jq/substring-4.jq
Normal file
6
Task/Substring/Jq/substring-4.jq
Normal 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] => 五六
|
||||
Loading…
Add table
Add a link
Reference in a new issue