Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

search a string

0 views
Skip to first unread message

mmyn...@prodigy.net

unread,
Jul 1, 2001, 1:08:32 AM7/1/01
to
All of the search functions that I can find in the elisp documentation
are used to search a buffer. How do I search a string?

My goal is to write a quick function that will return me a name
without some selected parts, either by searching for strings or regular
expressions in the source string. The second step would be to remove
the string I found. Maybe with replace-match?

Example:

myfile.gz would be myfile

If I always knew that the .gz would be on the end I think I could
somehow use substring to strip off the .gz part by stripping off the
last three characters.

What do you think?

--
MM

Eli Zaretskii

unread,
Jul 1, 2001, 7:30:18 AM7/1/01
to
mmyn...@prodigy.net wrote:
>
> All of the search functions that I can find in the elisp documentation
> are used to search a buffer. How do I search a string?
>
> My goal is to write a quick function that will return me a name
> without some selected parts, either by searching for strings or regular
> expressions in the source string. The second step would be to remove
> the string I found. Maybe with replace-match?

Using string-match and replace-match is the usual paradigm.

Another possibility is to use parenthesized subexpressions in the regexp
you pass to string-match, and then use substring with values returned by
match-beginning and match-end.

mmyn...@prodigy.net

unread,
Jul 1, 2001, 11:36:27 AM7/1/01
to
Thank you. :-)

BTW, where did you find this in the documentation. Now that I know
what it is called I can do a C-h f, but how did you find this prior to
knowing what it is?

Henrik Enberg

unread,
Jul 1, 2001, 11:45:26 AM7/1/01
to

M-x apropos lets you search for things with regular expressions. This should
not be confused with `apropos-command' (Bound to C-h a) which only shows
interactive commands.

If you don't have it already you should also get the Emacs-Lisp manual from
your closest GNU mirror.

Henrik
--
Soylent Green is People!

mmyn...@prodigy.net

unread,
Jul 1, 2001, 1:26:42 PM7/1/01
to
Henrik Enberg <henri...@enberg.org> writes:


> M-x apropos lets you search for things with regular expressions. This should
> not be confused with `apropos-command' (Bound to C-h a) which only shows
> interactive commands.

Cool! Thank you.


>
> If you don't have it already you should also get the Emacs-Lisp manual from
> your closest GNU mirror.

I have it and could not find the function I needed in the manual, that
is why I asked.

> Soylent Green is People!
Cool tag line. I have not heard a reference to Soylent Green in a
long time. :-)

Thanks again.

--
MM

those who know me have no need of my name

unread,
Jul 1, 2001, 7:03:54 PM7/1/01
to
<wkk81sw...@prodigy.net> divulged:

>BTW, where did you find this in the documentation. Now that I know
>what it is called I can do a C-h f, but how did you find this prior to
>knowing what it is?

you wanted to know something about searching, so bring up the manual and
use the `m' and `i' commands using that word or it's stem, e.g., ``\c-h i m
emacs <ret> m search <ret>''.

--
okay, have a sig then

0 new messages