Re: [GENERAL] Desperately Seeking Regular Expression

Поиск
Список
Период
Сортировка
От Adriaan Joubert
Тема Re: [GENERAL] Desperately Seeking Regular Expression
Дата
Msg-id 3725C3C3.2D9F32B0@albourne.com
обсуждение исходный текст
Ответ на Desperately Seeking Regular Expression  (Thomas Good <tomg@q8.nrnet.org>)
Список pgsql-general
I solved something like this recently in perl. It's not terribly
efficient, but it is simple. I'm doing this from memory, so it may need
some debugging. Use something along the lines of

#!/usr/local/bin/perl

while (<>) {
  @a = split /(\")/;
  # This gives you a list with some of the items being double-quotes
  # Now you need to figure out which ones were inside double quotes
  my $b;
  if ($a[0] eq '"') {
    # we started with a double quoted string, so join th e 1st 3 fields
        # and stick them on the new string
    $b = join('',splice(@a,0,3))."\t";
  }
  while (@a) {
    $b .= join("\t",split(' ',shift @a))."\t";
    # if there is more then we have another double quoted string
    $b = join('',splice(@a,0,3))."\t" if @a;
  }
  # Remove the last tab and replace with a newline
  $b =~ s/\t$/\n/;
  print $b;
}

Adriaan

В списке pgsql-general по дате отправления:

Предыдущее
От: Andy Lewis
Дата:
Сообщение: Re: [GENERAL] PL/pgSQL
Следующее
От: Tatsuo Ishii
Дата:
Сообщение: Re: [HACKERS] Re: [GENERAL] unknown symbol 'lo_unlink'