Substring/Top and tail: Difference between revisions
Content added Content deleted
m (→{{header|Ruby}}: added comment) |
(jq) |
||
Line 535: | Line 535: | ||
alert("brooms".slice(1, -1)); // strip both first and last characters</lang> |
alert("brooms".slice(1, -1)); // strip both first and last characters</lang> |
||
=={{header|jq}}== |
|||
jq uses 0-based indexing, so [1:] yields all but the first character, it being understood that data strings in jq are JSON strings. [0:-1], which can be abbreviated to [:-1], yields all but the last character, and so on. Here are some examples:<lang jq>"一二三四五六七八九十"[1:]' => "二三四五六七八九十" |
|||
"一二三四五六七八九十"[:-1]' => "一二三四五六七八九" |
|||
"一二三四五六七八九十"[1:-1]' => "二三四五六七八九" |
|||
"a"[1:-1] # => "" |
|||
</lang> |
|||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
<lang julia>julia> "My String"[2:end] # without first character |
<lang julia>julia> "My String"[2:end] # without first character |