unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Amy Templeton <amy.g.templeton@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: How to search a whole word in emacs?
Date: Fri, 26 Oct 2007 17:08:13 -0400	[thread overview]
Message-ID: <877il9h9du.fsf@gmail.com> (raw)
In-Reply-To: <1193422116.266878.76080@z24g2000prh.googlegroups.com> (webinfinite@gmail.com's message of "Fri\, 26 Oct 2007 18\:08\:36 -0000")

"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	other threads:[~2007-10-26 21:08 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-26 18:08 How to search a whole word in emacs? webinfinite
2007-10-26 21:08 ` Amy Templeton [this message]
2007-10-26 21:08 ` Eric Hanchrow
2007-10-26 21:54   ` David Hansen
2007-10-27 10:10     ` Dieter Wilhelm
2007-10-26 22:05   ` Drew Adams
2007-10-27  9:45 ` Johan Bockgård
     [not found] ` <mailman.2615.1193432708.18990.help-gnu-emacs@gnu.org>
2007-11-23  0:44   ` David Combs
2007-11-23  8:26     ` Xah Lee

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877il9h9du.fsf@gmail.com \
    --to=amy.g.templeton@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).