pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Chris Travers <chris@travelamericas.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: How to retrieve N lines of a text field.
Date: Thu, 29 Jan 2004 10:50:21 -0500
Message-ID: <22882.1075391421@sss.pgh.pa.us> (raw)
In-Reply-To: <010301c3e679$077698b0$5444053d@winxp>
References: <010301c3e679$077698b0$5444053d@winxp>

"Chris Travers" <chris@travelamericas.com> writes:
> However, this always selects every line but the final one (because %\n seems
> to be interpreted to be the largest possible string, while I want it to be
> the smallest possible string).

I don't think you can solve this in SQL99 regular expressions, but
if you use the POSIX-style regex operators, you can write something
like "[^\n]*\n" to match exactly one line.  There are other features
that might help too, such as the counted-match operator "{n}".
Read the man page.

BTW, I bought a copy of the O'Reilly book "Mastering Regular
Expressions" a couple years ago, and it is worth every penny
if you do much of anything with regexes.

			regards, tom lane



view thread (3+ messages)  latest in thread

Message-ID: <22882.1075391421@sss.pgh.pa.us>
Permalink:  ../22882.1075391421@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/22882.1075391421@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, chris@travelamericas.com
  Subject: Re: How to retrieve N lines of a text field.
  In-Reply-To: <22882.1075391421@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox