Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
%%
is one of many Parameter Substitution Operators in BASH.Source: https://tldp.org/LDP/abs/html/parameter-substitution.html
For context, here are my own practical descriptions of
%%
,%
,##
, and#
. I actually use these at the command line pretty often. Check out the source for definitive descriptions, as well as numerous examples.${a%%b*}
Remove the end of$a
, from right to left, ending on the leftmost pattern that starts with"b"
${a%b*}
Remove the end of$a
, from right to left, ending on the rightmost pattern that starts with"b"
${a##*b}
Remove the beginning of$a
, from left to right, ending on the rightmost pattern that ends in"b"
${a#*b}
Remove the beginning of$a
, from left to right, ending on the leftmost pattern that ends in"b"
Tips for remembering:
On a standard US keyboard,
#
is to the left of%
. Equivalently,%
is to the right of#
. This should help you remember which key to use.One
#
or%
means non-greedy, whereas two means greedy. Two is more than one, which should help you remember##
and%%
are greedy matches.Great way to bypass the -0 problem
It's not clear whether the code should assume single- or multi-byte strings. Assuming single byte strings makes things a lot easier.
This comment is hidden because it contains spoiler information about the solution
Thanks for the answer ctttttttttt.
This comment is hidden because it contains spoiler information about the solution
Intersting. Why does 0 - i produce 0 when i == 0 but -i produces -0?
This comment is hidden because it contains spoiler information about the solution