Reputation: 7633
Data format:
ab b c
ab b
abc d e
abcd e
Each row could be 2 or 3 columns, delimited by a white space. I want to match any row in which the first column length is 4. How do I do this?
I've tried to do the following:
/.... \{_}
But VIM reports a syntax error. Why is that?
Upvotes: 0
Views: 670
Reputation: 3576
Moving my comment into an answer. I suggest using /^[^ ]\{4} .*$
The first ^
matches the start of a line (so we know we're looking at the first column), the [^ ]\{4}
matches 4 characters that aren't spaces (so we don't match if it's fewer than 4 characters), the space after that matches a space (so we don't match a column with more than 4 characters), and the .*$
makes sure we match all the way to the end of the line (not sure if you actually care about that... if you're just seeking within the file it won't matter, but if you're replacing or something you might want it).
Upvotes: 3