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

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

Re: regex support


From: Llewelly
Subject: Re: regex support
Date: 28 Apr 2005 21:54:24 -0600
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

Ryan Bowman <address@hidden> writes:

> Does emacs support the regex syntax {4} or any of it's
> variants?

Yes. See C-h i g (emacs)Regexps

However you need to put a backslash before the curly braces:

\{4]\} instead of {4}

> I'd like to match a date a la 2005-04-19,
> so I'm trying (for the year part) something like
> "[0-9]{4}", but unless I'm doing something wrong it

"[0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}"

should do the trick. Note I used double backslashes (\\) within the
string. If your regex isn't in a string literal use single backslash
(\) .

> doesn't seem to be working.  Assuming it doesn't
> support that, is there a better way to match an string
> of digits of length 4 than "[0-9][0-9][0-9][0-9]"?
[snip]

hm... "[0-9]\\{4\\}" is fewer chars but "[0-9][0-9][0-9][0-9]" is
easier to read ...


reply via email to

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