Suppose we have a file containing lines of the following form (but the number of #'s is not fixed, and the length of fields is not fixed)
as#dviu#cvm#ud
For the above line, .*#
matches as#dviu#cvm#
(i.e. it goes as far as possible). How to match until the first occurrence of #
? (i.e. match only as#
)
Use [^#]
, instead of .
, to match anything except a #
.