0

I have a value which is duplicated from source (can't do anything about that). I have read some examples here https://docs.aws.amazon.com/redshift/latest/dg/REGEXP_REPLACE.html

Example value: ABC$ABC$ So just trimming anything after the first '€'. I tried this, but I cannot figure out the correct REGEX expression.

REGEXP_REPLACE(value, '€.*\\.$', '') 

3 Answers 3

2

Your current regex pattern is including a dot as the final character. Remove it and your approach should work:

SELECT REGEXP_REPLACE(value, '€.*$', '') AS value_out
FROM yourTable;
Sign up to request clarification or add additional context in comments.

Comments

2

So just trimming anything after the first '€'.

Why use regex at all? Why not just..

SELECT LEFT(value, CHARINDEX('€', value)-1) 

If not all your data has a euro sign, consider WHERE value like '%€%'

Comments

1

Or you can take the initial sequence of non-€ characters:

REGEXP_SUBSTR(value, '^[^€]+') 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.