[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Regexp for marking source code
From: |
David Kastrup |
Subject: |
Re: Regexp for marking source code |
Date: |
Wed, 09 Aug 2006 14:08:05 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
Dieter Wilhelm <dieter@duenenhof-wilhelm.de> writes:
> David Kastrup <dak@gnu.org> writes:
>
>> Ken Goldman <kgold@watson.ibm.com> writes:
>>
>>> The dired Q command seems quite useful, but
>>> regexp syntax is obscure enough that I can't quite
>>> get what I want.
>>>
>>> What would be a regexp for all .c and .h files.
>>> In a Unix shell, it would be *.[ch], What's the
>>> regexp equivalent?
>>
>> .*\.[ch]\'
>
> quick and dirty
>
> \.[ch]$
>
> since the likely hood of existing hidden files `.h' and `.c' is too
> small for the hassle of typing .*
That's not it. For matching, .* at the beginning is entirely
useless. If you want to avoid files .c and .h,
.\.[ch]\'
will do the trick. Replacing \' with $ means that you'll also match
multiline file names like
'x.h
whatever'
Probably not important in dired, but I have some healthy matching
paranoia. For example, if some joker creates a file (and its
containing directory) named
'-rf
/
guffaw'
which is infrequently cleaned up by a sysadmin script, things can get
ugly if the script has not been written carefully.
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum