Friday, February 6, 2015

Regex to find case differences

Assuming I have a list of names:

John.Smith            John.Smith
Joe.Blow                Joe.blow
Sarah.Smith           sarah.smith

So in the above list, I need to find Joe.Blow and Sarah.Smith, since the case (and or spelling) is different on the 2nd part of the line.


I couldn't come up with a way (assuming %s or Match or something) that would allow me to:

1.  For each line
2.  Grab the first text (^\S\+)
3.  Check the rest of the line to find a match (or better yet NOT match) using CaSe

I tried something like:
%s/^\(\S\+\)\s\+\=eval(submatch(1))

But I believe you can only use submatch() in the replacement part of the :substitute

Perhaps a :g might do it.

Vim 7.4.1-622

Any suggestions?

TIA,
David

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: