We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
It's a simple pattern substitution, from "man bash":
${parameter/pattern/string} Pattern substitution. The 'pattern' is expanded to produce a pattern just as in pathname expansion. 'Parameter' is expanded and the longest match of 'pattern' against its value is replaced with 'string'. If 'pattern' begins with /, all matches of 'pattern' are replaced with 'string'. Normally only the first match is replaced. If 'parameter' is an array variable subscripted with @ or *, the substitution operation is applied to each member of the array in turn, and the expansion is the resultant list.
The '?' character stands for 'any' character. Probably it would be better written as:
{ a=($(cat)); echo ${a[@]/#[A-Z]/.}; }
The first capital letter (only) will be replaced. (by @ariessa)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Remove the First Capital Letter from Each Element
You are viewing a single comment's thread. Return to all comments →
It's a simple pattern substitution, from "man bash":
${parameter/pattern/string} Pattern substitution. The 'pattern' is expanded to produce a pattern just as in pathname expansion. 'Parameter' is expanded and the longest match of 'pattern' against its value is replaced with 'string'. If 'pattern' begins with /, all matches of 'pattern' are replaced with 'string'. Normally only the first match is replaced. If 'parameter' is an array variable subscripted with @ or *, the substitution operation is applied to each member of the array in turn, and the expansion is the resultant list.
The '?' character stands for 'any' character. Probably it would be better written as:
{ a=($(cat)); echo ${a[@]/#[A-Z]/.}; }
The first capital letter (only) will be replaced. (by @ariessa)