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

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

Re: what means "\\s-" used as a regexp?


From: Michaël Cadilhac
Subject: Re: what means "\\s-" used as a regexp?
Date: Sat, 05 Aug 2006 13:59:48 +0200
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.50 (gnu/linux)

stefano.sabatini-lala@poste.it writes:

> Hello everybody.
>
> I recently found in some code the use of "\\s-". Documentation
> appearantly said nothing on it.
>
> (string-match "\\s-" "hello world")
> ==>5
>
> (string-match "\\s-" "hello\\tworld")
> ==>nil
>
> (string-match "\\s-" "hello\\nworld")
> ==>nil
>
> So it seems "\\s-" match only the space.
> But I still doesn't understand the  meaning of the hypen at the end of
> the
> regexp "\\s-".
>
> (string-match "\\s" "hello world")
> returns the error: (invalid-regexp "Premature end of regular
> expression")

,----[ (info "(Elisp)Regexp Backslash") ]
| `\sCODE'
|      matches any character whose syntax is CODE.  Here CODE is a
|      character that represents a syntax code: thus, `w' for word
|      constituent, `-' for whitespace, `(' for open parenthesis, etc.
|      To represent whitespace syntax, use either `-' or a space
|      character.  *Note Syntax Class Table::, for a list of syntax codes
|      and the characters that stand for them.
`----


-- 
 |      Michaël `Micha' Cadilhac   |  Would someone please DTRT with this,  |
 |         Epita/LRDE Promo 2007   |        then ACK?                       |
 | http://www.lrde.org/~cadilh_m   |          -- Richard Stallman           |
 `--  -   JID: micha@amessage.be --'                                   -  --'

Attachment: pgptlKmwKliH0.pgp
Description: PGP signature


reply via email to

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