0

I'm quite new to using POSIX regex in Redshift. I honestly think that this pattern must be compatible.

[^A-Za-z0-9\\.\\,-]+

However, as I've tried a query like this

SELECT * FROM my_table WHERE string_column ~ '[^A-Za-z0-9\\.\\,-]+';

it gives me a result that doesn't match with what I like, and it seems to be considering the caret as a character literal. I've also tried using [^[:alnum:]] to no avail. What could be the reason why this happens? Did I input something wrong, or is this a limitation within Redshift or the JDBC drivers?

I'm currently running queries through JetBrains DataGrip (latest version) and running it with the latest Amazon Redshift JDBC driver.

1 Answer 1

0

The problem with how I used this pattern is how I wrongly tried to add characters after the - character. Basically, Redshift does support the use of carets for pattern list matching negation. So this

[^A-Za-z0-9\\.\\,-]+

should not cause any problems, but

[^A-Za-z0-9\\.\\,-\\s]+

might cause problems because it might assume a range lookup instead for looking for both - and whitespace characters.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.