Re: [OT] regex

2005-12-26 Thread Artem Chuprina
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:  Jabber: [EMAIL PROTECTED]

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


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: [OT] regex

2005-12-27 Thread Степан Голосунов
On Mon, Dec 26, 2005 at 09:40:14PM +0200, Matvey wrote:
> Привет всем.
> 
> Что-то я с sed не могу объяснится:
> 
> $ ls
> 01-J'ysuis jamais alle.wav   
> 02-Les joors tristes.wav 
> 03-La Vaise d'Amelie.wav  
> 
> $ ls | sed -e s/.wav$// | sed -e s/^[0-9]\{,4\}-//
> 01-J'ysuis jamais alle
> 02-Les joors tristes
> 03-La Vaise d'Amelie
> 
> Почему не убирает циферки с черточкой вначале имени?
> Тупое 
> $ ls | sed -e s/.wav$// | sed -e s/^[0-9][0-9]-// 
> работает, но иногда бывают файлы с 3/4-значными номерами...

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

cat /tmp/tmp.CE6e3u | sed -e 's/^[0-9]\{,4\}-//'
J'ysuis jamais alle.wav
Les joors tristes.wav
La Vaise d'Amelie.wav

cat /tmp/tmp.CE6e3u | sed 's/\.wav$//; s/^[0-9]\{,4\}-//'
J'ysuis jamais alle
Les joors tristes
La Vaise d'Amelie


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]