Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
3 votes
1 answer
69 views

Extracting specific substrings from a text field in SQL

Consider this snippet code to regenerate the result set: CREATE SCHEMA "clean"; CREATE TABLE "clean"."InvoiceFact" ( "InvoiceTitle" TEXT ); INSERT INTO &...
sci9's user avatar
  • 776
-1 votes
0 answers
19 views

Oracle regexp_like is not working as expected [duplicate]

I was testing a regular expression in Oracle SQL and found something I could not understand. I would like to check if a varchar2 value is an integer between 0 and 99999. Both selects return 'PASS', ...
Eduardo's user avatar
  • 1,205
0 votes
1 answer
63 views

Extract Main Domain from URLs in PostgreSQL Without Subdomains, Ports, or Query Parameters

I’m working with a PostgreSQL query where I need to extract the main domain (including the second-level domain and top-level domain) from URLs. However, the current approach using REGEXP_MATCH or ...
sci9's user avatar
  • 776
1 vote
1 answer
48 views

How to Parse a field with Pattern “userid-date-amount” in postgresql

I’m working on a query where I need to parse Description field that follow the pattern “userid-date-amount-” For example, a valid value would be: 222826-2022/07/26-32,700,000- However, my current ...
sci9's user avatar
  • 776
1 vote
2 answers
65 views

Matches the same two digits that were captured in the first group

select * from bha b where b.bks similar to '\d{2}[A-Z](\d{2})\d\\1'; The purpose is to regex but bks is in the form 12A56856 12A12812 12A898389 Although I already have this data in my database, ...
Nguyễn Tuấn Hưng's user avatar
-2 votes
2 answers
36 views

Oracle regexp_replace entire matching word

Input: ABC DEF GHIJ123A KLM GHIJ456B RST UVW GHIJ789C Ouput: ABC DEF GHIJ000X KLM GHIJ000X RST UVW GHIJ000X So, I want to find all instances of words in the string that start with GHIJ and replace ...
Vani Narayana's user avatar
0 votes
1 answer
49 views

SQL Updating a table column from first 9 digits of another column

I have a USER table with SSN in one column and SSN +5 digits (lets just call SSNPLUS) in another column. The source for SSN has become corrupted for some rows, so I would like to update the SSN from ...
Twelve-0-Seven's user avatar
2 votes
2 answers
79 views

Alternative to \p{Lo} Unicode Class in PostgreSQL Regex

I encountered a problem when working with regular expressions in PostgreSQL. It turns out that PostgreSQL has no support for the \p{Lo} class, which corresponds to the "Letter, Other" ...
Pavel Kuharuk's user avatar
-1 votes
1 answer
42 views

Is there any SQL query to extract only number data

I want to ask how to extract only number which is not include word like ddd99938ddd 38483 eifn321ef I want to extract just 38483 using a SQL query. I tried to use REGEXP_REPLACE(text, '[^ 0-9]+', ''),...
hognkun's user avatar
  • 337
1 vote
1 answer
38 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 ...
insanity's user avatar
  • 1,168
-1 votes
1 answer
63 views

Combining SQL and Regex together?

I have a table pizza_orders with a column ingredients that looks like this: order_no ingredients 1 cheese-olives-peppers-olives 2 cheese-olives 3 cheese-tomatoes-olives 4 cheese I want to make 3 ...
wulasa's user avatar
  • 125
0 votes
1 answer
53 views

How to convert oracle regex pattern into Databricks compatible version?

Given this Oracle version with the goal to convert it so it is usable in Databricks SQL: WITH pattern AS ( SELECT /*+ INLINE */ '^([A-Z][A-Z0-9])([A-Z]\d{3,4})([T])?([A-D])?([W]\d)?([A-RT-Z][...
Wondarar's user avatar
  • 183
-1 votes
1 answer
59 views

Extract alphanumeric sequence SAS/PROC SQL

I'm converting some of my R code to SQL PROC for a program in SAS EG (V8.3.2.140), however I'm stuck. I need some help extracting a alphanumeric string from a column and make a new column with that ...
Justin's user avatar
  • 323
-2 votes
2 answers
67 views

How do I remove any text between parentheses, including the parentheses themselves? [duplicate]

I have a string in a table column that I want to remove the parentheses and their contents from. I'm working in Presto/Trino SQL. Example string: 'apple not found for (1) tree on farm (123) on highway ...
SqueakyBeak's user avatar
-3 votes
1 answer
42 views

Regex SQL to Pull Consecutive Numbers [closed]

I want to query only phone number with criteria triple repeated digit and at least repeated double digit from the following data. phone_number 8181122274 8218241857 8178924294 8198884442 I tried ...
steven fernando's user avatar

15 30 50 per page
1
2 3 4 5
236