Comment

Comment by js2

FYI, these substitutions are POSIX:

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V...

Also a couple mnemonic hints:

% vs #. On US keyboards, # is shift-3 and is to the left of % which is shift-5. So # matches on the start (left) and % matches on the end (right).

# vs ## (or % vs %%). Doubling the character makes the match greedy. It's twice a wide so it needs to eat more.

Bash also supports ${parameter/pattern/string} and ${parameter//pattern/string} (and a bunch others besides) which are not POSIX:

https://www.gnu.org/software/bash/manual/html_node/Shell-Par...

parent js2 2 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton