[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: query replace regex
From: |
james |
Subject: |
Re: query replace regex |
Date: |
21 Feb 2007 11:38:28 -0800 |
User-agent: |
G2/1.0 |
On Feb 21, 12:58 pm, Gary Wessle <phd...@yahoo.com> wrote:
> Hi
> I need to replace
> 452452451 1.4445 1.4254
> with
> 452452451 1 1
>
> so I started by search regex to find if I can get the regex correct.
> ^\\d* \\d\\.\\d* \\d\\.\\d*$
> is reporting fail as soon as I type the second "\" in the line.
>
> how can I do this task?
>
> many thanks
Also, for the literal period, you're double escaping it. A single \.
will do when orompted interactively. You only need to double-escape
them when using the regex is read from source, such as:
(add-to-list 'auto-mode-alist '("\\.php3?\\'" . sgml-html-mode))
The first escape is for the lisp reader(parser), the second is for the
regex parser.
Since you're more familiar with perly-regexen, you should also note
that a paren is taken literally. To use it for grouping you need to
escape it:
^\([0-9]*\) \([0-9]*\)\.[0-9]* \([0-9]*\)\.[0-9]*$