On Wed, Sep 07, 2005 at 05:26:07PM -0700, Matthew Peter wrote:
> Thanks. I'll check it out asap. I didn't realize the
> regex expressions needed to be escaped for it to be a
> valid expression.

If you use ordinary quotes (') around the regular expression then
you have to escape the backslashes because there's an extra level
of string parsing that you're probably unaccustomed to.  If you use
dollar quotes (available since 8.0) then you don't need the extra
escapes:

SELECT id, substring(content FROM $$((\S+\s*){1,3})$$) FROM article;

> Would it be possible to choose what paragraph to use in a summary?

You might be able to use split_part().  For example, if paragraphs
are separated by pairs of newline (\n) characters, then the following
should return each article's third paragraph:

SELECT id, split_part(content, '\n\n', 3) FROM article;

See "String Functions and Operators" and "Pattern Matching" in the
documentation for more information.  If you need to get fancy then
consider writing a function in a language like PL/Perl.

-- 
Michael Fuhr

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to [EMAIL PROTECTED] so that your
       message can get through to the mailing list cleanly

Reply via email to