[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: regexp-quote missing escapes in grouping constructs - Bug?
From: |
Miles Bader |
Subject: |
Re: regexp-quote missing escapes in grouping constructs - Bug? |
Date: |
Fri, 13 Jun 2008 15:17:34 +0900 |
"St/n_P/rm/n" <address@hidden> writes:
> (regexp-quote "[0-9]\{2,4\}\(-\|/\)[0-9]?+\(-\|/\)[0-9]\{2,4\}")
>
> ---> "\\[0-9]{2,4}(-|/)\\[0-9]\\?\\+(-|/)\\[0-9]{2,4}"
>
> Am I misunderstanding something?
The backslashes you entered in the original lisp string were eaten by
the lisp reader, so there are no backslashes in the string. Since (, ),
|, etc., are not emacs regexp metacharacters (without a preceding
backslash), there's no need to quote them.
Here's what you probably meant:
(regexp-quote "[0-9]\\{2,4\\}\\(-\\|/\\)[0-9]?+\\(-\\|/\\)[0-9]\\{2,4\\}")
=>
"\\[0-9]\\\\{2,4\\\\}\\\\(-\\\\|/\\\\)\\[0-9]\\?\\+\\\\(-\\\\|/\\\\)\\[0-9]\\\\{2,4\\\\}"
-Miles
--
Joy, n. An emotion variously excited, but in its highest degree arising from
the contemplation of grief in another.