split string by special characters - Mailing list pgsql-general

From Jan-Erik
Subject split string by special characters
Date
Msg-id 55ea945f-f135-451e-8c3b-23d177aa4692@g31g2000yqc.googlegroups.com
Whole thread Raw
Responses Re: split string by special characters
List pgsql-general
I wonder if you could please help me out to extract a character string
to an array or better yet, a table.

I'd like to split strings of text up into words and delimiters (but
not delete the delimiters). The delimiters are defined as comma,
space, dot, singe/double quotation mark, question mark etc.¹ in a
separate table (delimiters) depending on what rules apply for the
input.

regexp_split_to_array/table seem quite suitable but I have
difficulties to form the right expression with it, apart from that it
remove the delimiters as well.

Example:
This is just a text that contain special characters such as , (comma),
"(", ")" (left and right parenthesis) as well as "?" question mark.
How do I split it up with PostgreSQL?

Expected result:
{This, " ", is, " ", just, " ", a, ..., PostgreSQL, "?" }
__________________
¹)  Also later on tags such as <html> and at other times something
else depending on the circumstances.

//Jan-Erik

pgsql-general by date:

Previous
From: Matthew Seaborn
Date:
Subject: Search Path vs Synonyms
Next
From: Matt Harrison
Date:
Subject: Re: enabling join_collapse_limit for a single query only