help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to search a whole word in emacs?


From: Amy Templeton
Subject: Re: How to search a whole word in emacs?
Date: Fri, 26 Oct 2007 17:08:13 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/23.0.50 (gnu/linux)

"webinfinite@gmail.com" <webinfinite@gmail.com> wrote:
> I need to search a whole word in a big file. For example, I need to search
> "Machine" but I don't need to know anything like "machine_state",
> "running_machine_state" etc. The search shall be case sensitive.

> I've tried C-s ret C-w Machine but it returns every word with "Machine" in
> it. I just need the exact word.

Dear Web,

The following should do the trick, searching for the word "machine" either
at the beginning of a line and followed by a space, surrounded by spaces, or
preceded by a space and at the end of a line. Type the following (not the
bit with the dashes, though):

-----------------|CODE|-----------------
M-x re-search-forward RET
\(^\|[ \t]\)machine\([ \t]\|$\)
----------------------------------------

It's probably more constructive to copy the regexp than to type it all in.
This will place your cursor at the *end* of whatever it finds.

For more information, the section in the Info system on regexps is useful.

Amy

-- 
A day without orange juice is like a day without orange juice.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]