Questions tagged [regular-expression]
The regular-expression tag has no summary.
142 questions
0
votes
1
answer
9
views
Negative lookahead in table-matching pattern for psql or pg_dump
I'm trying to do a schema-only pg_dump of my database, however with data from one or two specific tables included. This means I can't use the --schema-only or --data-only options of pg_dump, and I can'...
2
votes
2
answers
325
views
(non-breaking space) is not considered whitespace by Postgres?
String-functions in Postgres do not recognize non-breaking-space as whitespace, neither when trimming nor when using regular expressions:
select 'x' || test || 'x'
, 'x' || trim(test) || 'x'
...
0
votes
3
answers
2k
views
Remove spaces and replace characters with regexp_replace()
I wish to ...
... remove spaces
... delete apostrophes
... replace 'é' and 'è' with 'e'
I use the function regexp_replace().
For the moment, I can delete the spaces but poorly. Indeed, when the ...
1
vote
1
answer
673
views
Regex help in Snowflake
I am trying to write a regex that can replace '[', ']' and '].' with '_' and in cases where ']' is the last character it should be replaced with '' but I am struggling to come up with a regex for it ...
0
votes
1
answer
228
views
Query for converting a column of numbers matching a regex in MySQL
I have a column which contains string values of the format e.g AB12345678 - two letters followed by 8 numeric digits.
I need to write a MySQL query to insert a 5 before each set of 4 digits thus ...
2
votes
3
answers
181
views
Find "naked" varchars
It is clear that omitting the length from a varchar is a bad thing. Unfortunately I am now working with a code base where this has happened. Extensively. I would like to correct this. The first step ...
0
votes
0
answers
107
views
Counting Rows From a Value in a SQL text box - please please can anyone help?
I just can't find an example of this anywhere and hoping someone can help.
I have a query which returns a list of care services and other fields based on the care service table values and calculated ...
0
votes
1
answer
331
views
Snowflake - extracting country/ state names - RegEx or Array?
I have a bunch of sloppy Geo text in a field.
However the country/ state names or codes are relatively clean.
It'll say Poland 23 or Illinois Remote or Frogballs, Germany or TX, AL, AK.
I have a ...
1
vote
2
answers
2k
views
Replace every character in each word, except the first two characters
Due to privacy concerns, I need to hide personal information, while remaining somewhat understandable. I propose to achieve that by hiding everything except the first two characters. The word length ...
0
votes
1
answer
1k
views
How to get exact match when the column used for filtering is comma-separated list in postgresql
I have a column which will have values like:
FC
FCW
FC,FCW
FX,FC
My input used for filtering should give correct result (match the exact value in the column)
ex:
FC like 'FC,FCW' --> true
FC like '...
5
votes
1
answer
1k
views
PostgreSQL - Index efficiently on REGEX_REPLACE()
I have a query which is designed to loop and search addresses for duplicates, the query uses REGEX_REPLACE. I am trying to index on the regex as on doing an explain and its doing a sequential scan on ...
0
votes
1
answer
933
views
How to replace repeating characters in a string with a single instance of the same character?
I have a column of urls with some of the urls like www.google.com///
Need them to be www.google.com/ instead.
4
votes
1
answer
1k
views
Index on expression (regular expression pattern matching) is not used in query
In my PostgreSQL 12.8 database, I have a relatively simple table the_table with a column value with type varchar:
CREATE TABLE public.the_table (
id uuid DEFAULT gen_random_uuid() NOT NULL,
...
2
votes
2
answers
550
views
Return part of a string with variable length
I have data in a table column like below:
host=0.0.0.0 port=5432 dbname=database_name user=pglogicaluser
host=0.0.0.0 port=5432 dbname=database_name2 user=pglogicaluser
I want to write a query to get ...
-1
votes
1
answer
6k
views
REGEXP_SUBSTR equivalent in MSSQL
I migrate from Oracle DB to Postgres/MS-SQL and I want to use REGEXP_SUBSTR equivalent with these databases. I need to rewrite this statement to these databases:
SELECT b.id,
b.name,
b....