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

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

Re: \t not correctly processed in query-replace-regexp


From: Andreas Schwab
Subject: Re: \t not correctly processed in query-replace-regexp
Date: Thu, 16 Sep 2004 17:27:07 +0200
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux)

"Paul vL" <litter@graffiti.net> writes:

> when using a character class with \t, the \t is not recognised:
> [ \t]+ will not match a sequence of spaces and tabs.

`[ \t]+' is a regexp that matches a sequence of SPC, backslash and `t'.

> using C-q to insert a literal tab character does work;
> [  ]+ will match a sequence of spaces and tabs.
>
> it is stated in the "syntax
> of regular expressions" section of the emacs manual/info file that :
> " `\"' stands for a double-quote as part of
> the regexp, `\\' for a backslash as part of the regexp, `\t' for a tab,
> and `\n' for a newline. "
> and it even gives an example which uses \t for tabs:
> "[.?!][]\"')]*\\($\\| $\\|\t\\|  \\)[ \t\n]*"

Here is the complete quote:

    In Lisp syntax, the string constant begins and ends with a
    double-quote.  `\"' stands for a double-quote as part of the regexp,
    `\\' for a backslash as part of the regexp, `\t' for a tab, and `\n'
    for a newline.

Note that it starts with "In Lisp syntax, the string constant ...",
ie. the paragraph talks about string syntax in Lisp, not about regexp
syntax.  The Lisp reader transforms this string constant according to the
quoted rules, and this transformed string is then interpreted by the
regexp engine.  The transformation of \t to TAB is only performed at the
Lisp level.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




reply via email to

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