Regex with logical not

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Regex with logical not

Chris Sutcliffe-2
Hi All,

I'm trying to do a search in a file for all lines that do not contain
an '@' and I'm having a hard time figuring out the proper regex.  Any
help would be greatly appreciated.

Thank you!

Chris

--
Chris Sutcliffe
http://emergedesktop.org
http://www.google.com/profiles/ir0nh34d

--
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
Reply | Threaded
Open this post in threaded view
|

Re: Regex with logical not

Adam-281
/^[^@]*$/

If you want to do something to the lines you can use the :v/@/

For example:

clear the 'c' register
    qcq

Find all the lines and copy them into the 'c' register
    :v/@/y C

~Adam~


On Wed, Jul 21, 2010 at 10:57, Chris Sutcliffe <[hidden email]> wrote:
Hi All,

I'm trying to do a search in a file for all lines that do not contain
an '@' and I'm having a hard time figuring out the proper regex.  Any
help would be greatly appreciated.

Thank you!

Chris

--
Chris Sutcliffe
http://emergedesktop.org
http://www.google.com/profiles/ir0nh34d

--
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 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
Reply | Threaded
Open this post in threaded view
|

Re: Regex with logical not

Benjamin Esham
In reply to this post by Chris Sutcliffe-2
Chris Sutcliffe wrote:

> Hi All,
>
> I'm trying to do a search in a file for all lines that do not contain an
> '@' and I'm having a hard time figuring out the proper regex.  Any help
> would be greatly appreciated.

Hi Chris,

Please see http://vim.wikia.com/wiki/Search_for_lines_not_containing_pattern_and_other_helpful_searches

Cheers,
--
Benjamin D. Esham   |   [hidden email]
“But the [ocean] Goddess, as quite a few New Agers fail to grok,
is not just the comforting image of “Mother Nature”... sometimes
she is an earthquake, tornado, and hurricane-throwing /bitch/.”
                                        — localroger on kuro5hin

--
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
Reply | Threaded
Open this post in threaded view
|

Re: Regex with logical not

lessthanideal
In reply to this post by Chris Sutcliffe-2
On Jul 21, 4:57 pm, Chris Sutcliffe <[hidden email]> wrote:

> I'm trying to do a search in a file for all lines that do not contain
> an '@'

1) This regex isn't using a logical not, it positively search for
lines that
don't include that character.

^[^@]*$

2) Depending on your task, maybe you could use the :v command
to execute a command on all lines that don't match the pattern @

:help :v

3) For the more general case of inverting patterns, I think this
plugin
"LogiPat" from Dr Chip Campbell may do what you want.

http://www.vim.org/scripts/script.php?script_id=1290

regards,
Geoff

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