Re: [GENERAL] Desperately Seeking Regular Expression

From: Adriaan Joubert <a(dot)joubert(at)albourne(dot)com>
To: Thomas Good <tomg(at)q8(dot)nrnet(dot)org>
Cc: Postgres-General <pgsql-general(at)postgreSQL(dot)org>
Subject: Re: [GENERAL] Desperately Seeking Regular Expression
Date: 1999-04-27 14:03:47
Message-ID: 3725C3C3.2D9F32B0@albourne.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tatsuo Ishii 1999-04-27 15:02:45 Re: [HACKERS] Re: [GENERAL] unknown symbol 'lo_unlink'
Previous Message Andy Lewis 1999-04-27 13:38:00 Re: [GENERAL] PL/pgSQL