[SQL] regexp_replace behavior

2012-11-20 Thread Marcin Krawczyk
Hi list, I'm trying to use regexp_replace to get rid of all occurrences of certain sub strings from my string. What I'm doing is: SELECT regexp_replace('F0301 305-149-101-0 F0302 {x1} 12W47 0635H {tt}{POL23423423}', E'\{.+\}', '', 'g') so get rid of whatever is between { } along with these,

Re: [SQL] regexp_replace behavior

2012-11-20 Thread Alvaro Herrera
Marcin Krawczyk escribió: Hi list, I'm trying to use regexp_replace to get rid of all occurrences of certain sub strings from my string. What I'm doing is: SELECT regexp_replace('F0301 305-149-101-0 F0302 {x1} 12W47 0635H {tt}{POL23423423}', E'\{.+\}', '', 'g') so get rid of whatever

Re: [SQL] regexp_replace behavior

2012-11-20 Thread Marcin Krawczyk
Yes that's exactly what I needed. Thanks a lot. pozdrowienia mk 2012/11/20 Alvaro Herrera alvhe...@2ndquadrant.com Marcin Krawczyk escribió: Hi list, I'm trying to use regexp_replace to get rid of all occurrences of certain sub strings from my string. What I'm doing is: SELECT

Re: [SQL] regexp_replace and search/replace values stored in table

2010-05-02 Thread Sofer, Yuval
yuval_so...@bmc.com -Original Message- From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql-ow...@postgresql.org] On Behalf Of Leif Biberg Kristensen Sent: Saturday, May 01, 2010 8:29 PM To: pgsql-sql@postgresql.org Subject: Re: [SQL] regexp_replace and search/replace values stored

[SQL] regexp_replace and search/replace values stored in table

2010-04-27 Thread Leif Biberg Kristensen
I've got a system for entering and storing a lot of standard hyperlinks in a compact form, and then expand them at run time like this: CREATE OR REPLACE FUNCTION _my_expand(TEXT) RETURNS TEXT AS $$ -- private func, expand various compact links DECLARE str TEXT = $1; BEGIN -- Scanned

Re: [SQL] regexp_replace and search/replace values stored in table

2010-04-27 Thread Tim Landscheidt
Leif Biberg Kristensen l...@solumslekt.org wrote: [...] So far, so good. But when I try to do the actual expansion, I'm stumped. pgslekt= select regexp_replace((select source_text from sources where source_id=23091), (select quote_literal(short_link) from short_links where link_type =

Re: [SQL] regexp_replace and search/replace values stored in table

2010-04-27 Thread Leif Biberg Kristensen
On Tuesday 27. April 2010 15.04.23 Tim Landscheidt wrote: Leif Biberg Kristensen l...@solumslekt.org wrote: [...] So far, so good. But when I try to do the actual expansion, I'm stumped. pgslekt= select regexp_replace((select source_text from sources where source_id=23091), (select

Re: [SQL] regexp_replace and search/replace values stored in table

2010-04-27 Thread Leif Biberg Kristensen
On Tuesday 27. April 2010 13.43.48 Leif Biberg Kristensen wrote: CREATE TABLE short_links ( link_type CHAR(2) PRIMARY KEY, short_link TEXT, long_link TEXT, description TEXT ); It appears like I have to double the number of backslashes when I enter the data: INSERT

Re: [SQL] regexp_replace and search/replace values stored in table

2010-04-27 Thread Leif Biberg Kristensen
Followup. Replaced Big Ugly Function with: CREATE OR REPLACE FUNCTION _my_expand(TEXT) RETURNS TEXT AS $$ -- private func, expand various compact links DECLARE str TEXT = $1; links RECORD; BEGIN FOR links IN SELECT short_link, long_link FROM short_links LOOP str :=

Re: [SQL] regexp_replace and UTF8

2009-01-31 Thread Jasen Betts
On 2009-01-30, Bart Degryse bart.degr...@indicator.be wrote: --=__Part8EA648F8.0__= Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi, I have a text field with data like this: 'de pati#235;nt niet' (without the quotes). I would like to convert this

[SQL] regexp_replace and UTF8

2009-01-30 Thread Bart Degryse
Hi, I have a text field with data like this: 'de pati#235;nt niet' (without the quotes). I would like to convert this string to look like this: 'de patiënt niet' Basically what I need to do (I think) is - get rid of the , # and ; - convert the number to hex - make a UTF8 from that (thus: \xEB) -

Re: [SQL] regexp_replace and UTF8

2009-01-30 Thread Gregory Stark
Bart Degryse bart.degr...@indicator.be writes: Hi, I have a text field with data like this: 'de pati#235;nt niet' Can anyone help me fix this or point me to a better approach. By the way, changing the way data is put into the field is unfortunately not an option. Many thanks in advance.

[SQL] regexp_replace

2008-08-01 Thread Marcin Krawczyk
Hi all. I'd like to know whether it's possible to reverse the behaviour of regexp_replace, meaning : now if I do SELECT regexp_replace ('foobarbaz', 'b..', 'X') I get 'fooXbaz' - it replaces the string that matches given pattern with 'X', how do I achieve the opposite - replace the string that

Re: [SQL] regexp_replace

2008-08-01 Thread Pawel Socha
2008/8/1 Marcin Krawczyk [EMAIL PROTECTED] Hi all. I'd like to know whether it's possible to reverse the behaviour of regexp_replace, meaning : now if I do SELECT regexp_replace ('foobarbaz', 'b..', 'X') I get 'fooXbaz' - it replaces the string that matches given pattern with 'X', how do I

Re: [SQL] regexp_replace

2008-08-01 Thread Marcin Krawczyk
thanks / dzieki regards / pozdrowienia mk 2008/8/1 Pawel Socha [EMAIL PROTECTED]: 2008/8/1 Marcin Krawczyk [EMAIL PROTECTED] Hi all. I'd like to know whether it's possible to reverse the behaviour of regexp_replace, meaning : now if I do SELECT regexp_replace ('foobarbaz', 'b..', 'X') I

Re: [SQL] regexp_replace usage

2006-10-02 Thread chester c young
Thanks !Michael Fuhr [EMAIL PROTECTED] wrote:Offhand I can't think of a way to do what you want with regexp_replace()but you could use PL/Perl. Something like this should work:CREATE FUNCTION mcfix(text) RETURNS text AS $$ $_[0] =~ s/\bMc([a-z])/Mc\u$1/g; return $_[0];$$ LANGUAGE plperl

Re: [SQL] regexp_replace usage

2006-10-01 Thread Michael Fuhr
On Fri, Sep 29, 2006 at 02:31:12PM -0700, chester c young wrote: column name in table bue has miscapitalized Mc names, eg, 'John Mcneil' instead of 'John McNeil'. (this should be easy but) how do you construct the update query? also, regexp_string( 'Mcneil', 'Mc(.*)', initcap('\\1') ) =

[SQL] regexp_replace usage

2006-09-29 Thread chester c young
column name in table bue has miscapitalized Mc names, eg, 'John Mcneil' instead of 'John McNeil'.(this should be easy but) how do you construct the update query?also, regexp_string( 'Mcneil', 'Mc(.*)', initcap('\\1') ) = 'neil' _not_ Neil' - is this correct? All-new Yahoo! Mail - Fire up a