All Questions
Tagged with amazon-redshift regex
145 questions
0
votes
1
answer
60
views
Regex to identify all "special" characters
I have a table, sales, with a column, email_address. I want to filter to only include records in the sales table that have any characters that are neither alphanumeric nor special characters. These ...
4
votes
4
answers
112
views
Regexp : any chr but ignore word
Trying to capture server names from string.
A server name can be
letters + digits
letters + digits + letters (but not 'root')
Problem is that in circumstances the word 'root' gets added to the end ...
2
votes
1
answer
381
views
change column names using a dbt macro
Can I use a dbt macro to modify the column names in AWS redshift?
Example changes to be made:
"checkedAt" --> checked_at
"helloWorld" --> hello_world
"testKitchenNew&...
1
vote
1
answer
45
views
Regular Expresssion find Comma in Redshift Database
I have a query which is having , in lname column. I want to find the , and replace it with blank. I want to use regex_substr but not getting any solution.
As of now i am able to resolve this using ...
0
votes
3
answers
71
views
Redshift query with regexp_replace works in Redshift console but not Python lambda
One of the fields in my Redshift table is structured like {event_type} 2024-01-01, so I am using regexp_replace to remove the date from the event type. I am calling Redshift via a Python Lambda like ...
0
votes
0
answers
38
views
How to check length of Redshift (postgres) regexp_substr output?
SELECT
data
,regexp_substr(data,'bottle~([[:alnum:]]{32})', 1, 1, 'ep') as bval
,len(bval) as WhyIsntThisAlways32or0
FROM activity
WHERE TRUE
;
Data records look like this: bottle~...
0
votes
1
answer
135
views
New line not detected in Regex in Redshift regexp_instr
I have a few strings string like this
"src=
https://media.hello.com/abc/def.png
xyz"
"src=
https://media.hello.com/tys/sdfjkhsdkjf.png
xyz"
"src=https://media.hello.com/tysds/...
0
votes
1
answer
367
views
How is the regex for extracting domain from URL constructed [duplicate]
I saw an SO answer here which has the SQL to extract domain from a URL in Redshift. I am very new to Regex. Is it possible to understand the answer step by step?
REPLACE(REGEXP_SUBSTR(url,'//[^/\\\,=@\...
0
votes
1
answer
561
views
Remove unicode control characters in redshift
I want to convert this javascript to redshift sql:
str.replace(/[\u0000-\u001F\u007F-\u009F]/g, " ");
I tried this, and a bunch of variations, at one point it was removing the ascii ...
1
vote
2
answers
176
views
How to extract the values assigned to x from this string?
I am trying to create a regex that I can use to extract out the values assigned to variable x in the following string:
(req.idf=6ca9a AND (req.ster=201 OR req.ster=st_home) AND (req.ste=hi OR req....
1
vote
1
answer
637
views
Regular expression in Redshift that returns all words prior to " at" in a string
Using REGEX_SUBSTR() in redshift I want to search a string and extract all words that precede " at" in a string. the space before the at is key.
I tested [^.]*(?=\sat) on regex tester it ...
-1
votes
1
answer
30
views
Drop whitespace only between digits and non digits - Redshift
I'm trying to drop the whitespace between digits and non digits, somehting like this:
medication_component
CLORIDRATO DE TRAMADOL 37.5 MG E PARACETAMOL 325 MG
ATEZOLIZUMABE 1.200 MG
ATENOLOL 25 MG
...
0
votes
1
answer
164
views
Replace digits and non digits that are joined together - Redshift
I am trying to replace with a blank space the digits and non digits that are joined together immediately after the name of the medication:
Table:
molecule_name
DOXICICLINA 100MG
CAFEINA 50MG E ...
1
vote
1
answer
81
views
Replace delimiter between non-digits - Redshift
I am trying to execute a query to replace dot (.) with a comma (,) only in positions where the dot is between non-digits.
Table:
full_name
LISADOR. COMPRIMIDO (16UN)
ALOPURINOL 1.0MG. COMPRIMIDO (...
-1
votes
1
answer
101
views
Remove items in a delimited list that are non numeric in SQL for Redshift
I am working with a field called codes that is a delimited list of values, separated by commas. Within each item there is a title ending in a colon and then a code number following the colon. I want a ...