Split_part on a CR

Поиск
Список
Период
Сортировка
Искать

Split_part on a CR

От:
Jeff Ross <jross@wykids.org>
Дата:
Hi,

I'm having a hard time figuring out how to use split_part with a 
carriage return (hex 0a) as the delimiter.

Would someone please offer me a clue?

Thanks!

Jeff Ross

Re: Split_part on a CR

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Jeff Ross  writes:
> Hi,
> I'm having a hard time figuring out how to use split_part with a 
> carriage return (hex 0a) as the delimiter.

Um, 0x0a is line feed last I checked.  But you should be able to write
the literal as E'\r' (if you wanted CR) or E'\n' (if you wanted LF).

			regards, tom lane

Re: Split_part on a CR

От:
Gary Chambers <gwchamb@gwcmail.com>
Дата:
Jeff,

> I'm having a hard time figuring out how to use split_part with a carriage
> return (hex 0a) as the delimiter.  Would someone please offer me a clue?

0x0a is actually a new line.  This works for me:
select split_part(text_column, E'\n', 1) from table;

--
GC

Re: Split_part on a CR

От:
"David Johnston" <polobo@yahoo.com>
Дата:
> -----Original Message-----
> From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-
> owner@postgresql.org] On Behalf Of Jeff Ross
> Sent: Monday, November 19, 2012 2:49 PM
> To: pgsql-general@postgresql.org
> Subject: [GENERAL] Split_part on a CR
> 
> Hi,
> 
> I'm having a hard time figuring out how to use split_part with a carriage
> return (hex 0a) as the delimiter.
> 
> Would someone please offer me a clue?
> 
> Thanks!
> 
> Jeff Ross
> 

SELECT split_part(E'a\nb\nc', E'\n', 2) --  == 'b'

David J.



Re: Split_part on a CR

От:
Jeff Ross <jross@wykids.org>
Дата:
On 11/19/12 12:58, Tom Lane wrote:
> Jeff Ross  writes:
>> Hi,
>> I'm having a hard time figuring out how to use split_part with a
>> carriage return (hex 0a) as the delimiter.
>
> Um, 0x0a is line feed last I checked.  But you should be able to write
> the literal as E'\r' (if you wanted CR) or E'\n' (if you wanted LF).
>
> 			regards, tom lane
>
>

Arrrggghhh!  I *knew* it was going to be something simple.

Thanks again all,

Jeff

FAQ