Using regular expressions with Redshift

Six Stars

Using regular expressions with Redshift

Hi,

 

I am using a tRedshiftRow component to update a Redshift table. Within the update statement , I am using the Redshift regex_replace function to remove multiple consecutive whitespaces. If I execute the update statement outside of Talend, via a Redshift client, the update statement works as it should be. However, when being executed during via Talend, multiple whitespaces are not being replaced, but words containing 'ss' are being replaced with a whitespace.

 

The regex expression used is: regex_replace(word, '\\s{2,}',' ')

 

I tried removing one of the back-slashes but it gave an error. 

 

Any hints on how to solve this by keeping the query intact?

 

Thanks,

Twelve Stars

Re: Using regular expressions with Redshift

if You use this function in SQL code, like "select regex_replace(word, '\\s{2,}',' ') from ...", java look for \\ as for \

 

so You need use - regex_replace(word, '\\\\s{2,}',' ')

-----------