I have a bunch of csv files which look sort of like this:


now I would like to search for every line where receiver and client are identical. Can this be done with a regex search?

1 Answer 1


So you want to skip the first column (comma delimited) and search for everything, where the second column is the same as the third column.

As a regex this can be written like this:

|  |  |  | |  |   || └ Same match as what was captured
|  |  |  | |  |   |└   Comma 
|  |  |  | |  |   └    End of captured group
|  |  |  | |  └        Any number of non-commas
|  |  |  | └           Capture the following
|  |  |  └             Start the match here
|  |  └                A comma
|  └                   Any number of non-commas
└                      Start of line

You can use :set hls to have a visual indication of what lines match the pattern.

Now if you want to delete those matching lines, you can simply use a :g command, which basically means, do for all lines that match a certain pattern:


Or, if you already have the pattern in the search register (e.g. all matching lines are already colored), you can even simplify this call to:


Which means, delete all the lines that match the last entered search pattern.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.