Questions tagged [regex]

The term REGEX is a shortening of the phrase "regular expression". A regex is typically a sequence of characters that forms a search pattern, mainly for use in pattern matching with strings.

76 questions
20
votes
3 answers

What is it called when you search the middle of a string instead of the beginning?

I am trying to polish up my vocabulary to better communicate with my fellow developers. We have several places in the site where we are debating if we should search for a string from the beginning 'running%' vs anywhere in the string '%running%. I…
danielson317
  • 343
  • 2
  • 9
19
votes
1 answer

Querying non-ASCII rows from Postgres

Does [:ascii:] class work in Postgres at all? It is not listed in their help, however I see examples in the web which utilize it. I have a UTF-8 database, where collation and c_type are en_US.UTF-8, and Postgres version is 9.6.2. When I search for…
Suncatcher
  • 357
  • 2
  • 4
  • 12
6
votes
3 answers

SQLite, ASCII A-Z Check Constraint

I have the following table which I'm trying to limit the column "prefix" to ASCII alphabetical characters. However, I am still able to insert other characters after using the following constraint. Why is it not working? CREATE TABLE test ( id…
z64
  • 61
  • 1
  • 2
5
votes
1 answer

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 the user_property table with a filter on the…
rdbmsNoob
  • 389
  • 2
  • 14
5
votes
2 answers

Capitalize first letter with exceptions

I need to properly format some European addresses. One of the steps is to capitalize the first letter, but avoiding some specific words, like 'on', 'upon', 'von', 'van', 'di', 'in', 'sul'. Therefore, although my skills are scarce, I thought it was a…
Joe
  • 359
  • 2
  • 12
5
votes
1 answer

Repeating pattern X amount of times in LIKE

I took a look at the documentation for patterns from Microsoft (can be found here), and from what I understood, it doesn't say a way for a pattern to repeat a limited number of times. It's either the wildcard (which goes on indefinitely) or looking…
Salmononius2
  • 451
  • 2
  • 5
  • 15
4
votes
1 answer

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, label character varying, value character…
4
votes
2 answers

Is there an operator or an easy way to match an expression one or more times with the LIKE operator in SQL?

For example if I run the following query, the expression in the WHERE clause will only match on the first letter before a number but is there a way to match on one or more letters first (e.g. in the case where there's a variable number of letters…
J.D.
  • 30,123
  • 7
  • 45
  • 96
4
votes
2 answers

How to split numbers and text in MySQL

I have searched over the internet looking for a function like REGEXP_REPLACE in Oracle, regexp_replace in PostgresSQL but I haven't find one similar in MySQL just REGEXP and RLIKE, but these operators just check whether the string matches pattern…
oNare
  • 3,092
  • 2
  • 19
  • 35
3
votes
2 answers

How To Exclude Queries Returned From mysqldumpslow Command

I would like to ignore queries in the mysql-slow log that originate from running the command mysqldumpslow by using SQL_NO_CACHE as the trigger word. My experience using regex are limited at best and I'm unable to find any examples in the docs. I've…
KDrewiske
  • 131
  • 1
3
votes
1 answer

Convert column value stripping html tags into sql view with rows and columns

I have a table named data with a column pid & display_data. Pid is the serial number of all rows. The value of display_data column is as below : For each row display_Data has values in the format => For PID= 1: The labels are constant for all rows…
Velocity
  • 101
  • 8
3
votes
0 answers

check if MySQL is using the Henry Spencer implementation for REGEX

Prior to MySQL 8.0.4, MySQL used the Henry Spencer implementation for REGEX and you could use this for word boundaries: '[[:<:]]' and '[[:>:]]' From 8.0.4 MySQL is using the ICU implementation and the word boundaries have changed to this: '\\b' I…
freejack
  • 131
  • 2
3
votes
2 answers

Convert Ruby regex to Postgres regex, for selecting invalid email addresses

I've done some internet trawling, and some reading of the Postgres regex docs, but I'm at the stage where I think asking a question here is the best thing to do. I have the following Ruby regex: /\A[^@\s]+@([^@\s]+\.)+[^@\W]+\z/ Which I am trying…
samjewell
  • 131
  • 4
3
votes
2 answers

Update fields that contains certain prefix by lookup table

I have a temporary table #NAMEOLD_NAMENEW which contains a column NAMEOLD and a column NAMENEW where every row contains the old and new value of a value to be updated. This table consists of roughly 2.000 rows. I created a clustered index on…
user2609980
  • 203
  • 1
  • 4
  • 11
3
votes
1 answer

Unicode error with \u0000 on COPY of large JSON file into Postgres

I'm using Postgres 9.4 on Ubuntu 14.04. I have a 30GB JSON file that I'm trying to COPY into Postgres. But I keep getting the following error: COPY (comment_jsonb) FROM '' WITH (format csv, quote e'\x01', delimiter e'\x02', escape…
alxlvt
  • 271
  • 3
  • 8
1
2 3 4 5 6