On Tue, Mar 26, 2013 at 09:13:39AM -0400, James Sharrett wrote:
> Sorry, caught a typo. Mytext1 is correctly replaced because only one
> instance of the character (space) is in the string.
>
> This deals with the correct characters but only does the first instance of
> the character so the output is:
>
> 'Mytext1'
> 'Mytext 2' (wrong)
> 'Mytext-3' (wrong)
> 'My_text4'
> 'My!text5'
>
Hi James,
Try adding the g flag to the regex (for global). From the documentation:
regexp_replace('foobarbaz', 'b..', 'X') fooXbaz
regexp_replace('foobarbaz', 'b..', 'X', 'g') fooXX
regexp_replace('foobarbaz', 'b(..)', E'X\\1Y', 'g') fooXarYXazY
Regards,
Ken