taji01 taji01 - 3 months ago 7
Linux Question

Search VI for letters and numbers

I use vi at work and i have to search for a string of specific letters & numbers such as these:

UTL41650
adr21100
aTL31901

there are always (3)Letters and (5)Numbers. Is there a way to search for these strings easily? Maybe with regex or something else.

Answer

Just type

/\v[a-zA-Z]{3}\d{5}

The \v activates the very magic mode to avoid escaping here. What follows is probably self-explanatory, assuming you know that \d is a digit in regular expressions.

Documentation on searching in vim