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

Re: [OT] regex



Matvey -> debian-russian@lists.debian.org  @ Mon, 26 Dec 2005 21:40:14 +0200:

 M> Привет всем.

 M> Что-то я с sed не могу объяснится:

 M> $ ls
 M> 01-J'ysuis jamais alle.wav                   
 M> 02-Les joors tristes.wav                     
 M> 03-La Vaise d'Amelie.wav                  

 M> $ ls | sed -e s/.wav$// | sed -e s/^[0-9]\{,4\}-//
 M> 01-J'ysuis jamais alle
 M> 02-Les joors tristes
 M> 03-La Vaise d'Amelie

 M> Почему не убирает циферки с черточкой вначале имени?
 M> Тупое 
 M> $ ls | sed -e s/.wav$// | sed -e s/^[0-9][0-9]-// 
 M> работает, но иногда бывают файлы с 3/4-значными номерами...

Глядя на man 7 regex:

       A bound is `{' followed by an unsigned decimal integer,  possibly  fol-
       lowed  by  `,'  possibly  followed by another unsigned decimal integer,
       always followed by `}'.  The integers must lie between 0 and RE_DUP_MAX
       (255(!))  inclusive,  and  if  there are two of them, the first may not
       exceed the second.  An atom followed by a bound containing one  integer
       i and no comma matches a sequence of exactly i matches of the atom.  An
       atom followed by a bound containing one integer i and a comma matches a
       sequence of i or more matches of the atom.  An atom followed by a bound
       containing two integers i and j matches  a  sequence  of  i  through  j
       (inclusive) matches of the atom.

Я не вижу здесь разрешения пропускать первое число.  А еще стоит
поиграться с бэкслешами - по историческим причинам одни хотят \ перед {,
другие, наоборот, нет.  И не забыть, что для шелла \ - тоже метасимвол.

-- 
Artem Chuprina
RFC2822: <ran{}ran.pp.ru> Jabber: ran@jabber.ran.pp.ru

kernel bug (англ.) - ядрёна вошь



Reply to: