The pattern [a-z]*
matches zero or more characters in the range a
to z
(the actual characters are dependent on the current locale). There are zero such characters at the very start of the string 123 abc
(i.e. the pattern matches), and also four of them at the start of this is a line
.
If you need at least one match, then use [a-z][a-z]*
or [a-z]\{1,\}
, or enable extended regular expressions with sed -E
and use [a-z]+
.
To visualize where the pattern matches, add parentheses around each match:
$ sed 's/[a-z]*/(&)/' file
()123 abc
(this) is a line
Or, to see all matches on the lines:
$ sed 's/[a-z]*/(&)/g' file
()1()2()3() (abc)
(this) (is) (a) (line)
Compare that last result with
$ sed -E 's/[a-z]+/(&)/g' file
123 (abc)
(this) (is) (a) (line)
ls foo*
there uses). But anyway, if you find questions that are duplicates, I think you should be able to flag them as such, too. – ilkkachu May 20 '18 at 14:58