Re: Silly little regex question
$ julyear=000009; echo ${julyear//0/};
9
I don't know why # doesn't do what you want, but I suspect that it
has to do with "maximal" aka "greedy" matching, or multiple matching.
Another related (and shorter) sed expression
s/^0//
will remove a single leading zero.
s/^0*//
will remove as many leading zeros as possible (greedy).
If a s/ expression is appended with a "g", then that match happens
multiple times (as with bash "//" as opposed to "/").
$ echo 'foo' |sed -e 's/o//'
fo
$ echo 'foo' |sed -e 's/o//g'
f
--
Justin Pryzby
Now seeking qualified employers.
Reply to: