LoMaPh
LoMaPh

Reputation: 1720

Match until the first occurance of a symbol

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#)

Upvotes: 0

Views: 51

Answers (1)

chepner
chepner

Reputation: 532238

Use [^#], instead of ., to match anything except a #.

Upvotes: 2

Related Questions