Questions tagged [regular-expression]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
3
votes
2answers
114 views

How to use “regular expression” to separate specific strings in Oracle

I have a string '(1:30,2:4,52:0,8:1)', and I need to use a regular expression to have this output: field1 field2 level 1 30 1 2 4 2 52 0 3 8 1 ...
0
votes
1answer
23 views

Need help with Regex in SQL Server query editior

I have a file with thousand lines of codes with index details like below: IF NOT EXISTS (SELECT 1 FROM SYS.INDEXES WITH (NOLOCK) WHERE name = 'IX_Test1' AND [object_id] = OBJECT_ID(N'Test1', N'U')) ...
0
votes
1answer
298 views

How can I search for a hex string in oracle?

There's a database record that is incorrect. The name field displays like this in a browser ( this is incorrect ): Thcˇodore And when I look at the record via SQL results, I see: Thc\xCB\x87odore ...
1
vote
1answer
57 views

Compare The length of two string variables inside an Expression task in SSIS

Hope you're doing well. I need to compare the Length of two string variables inside an expression task in SSIS so that if they have the same length the package will execute the next step and if not it ...
0
votes
1answer
256 views

Timestamp and substring with regular expression

I am using postgresql and I have the following table Table "public.test" Column | Type | Modifiers --------+--------------------------+----------- name | text ...
1
vote
1answer
2k views

PostGres - How to Extract SubString between two positions

I have a text column (emailbody) in a table (notification) which keeps a record of the HTML that went out for a particular email. Somewhere inside that HTML file, there is a line of text that contains ...
1
vote
1answer
305 views

Postgres not using expression index

I am using Postgres 9.5. It is possible this is related to the changes in 9.6 pointed out by PostgreSQL not using index during count(*), but I cannot be sure yet. I have a table that has a character ...
0
votes
1answer
2k views

oracle regexp_replace to remove duplicate duplicate strings and double separators

Been using the following regexp_replace to create a comma separated string for those values in 'col_name' and remove any duplicates. REGEXP_REPLACE(RTRIM(XMLAGG(XMLELEMENT(E,col_name,',').EXTRACT('//...
1
vote
1answer
378 views

Implement check constraint for varchar (7) to enforce YYYY-MM

I am considering the following with regards to implementing a check constraint on a column I am calling year_month. My objective is to have a check constraint to enforce YYYY-MM. My intention is to ...
1
vote
1answer
1k views

Select Statement with RegEx Replace - DB2 9.7

In a db2 9.7 select statement's field, I need to perform a global regular expression that replaces multiple white spaces (between words) with exactly one space. The regular expression would be base on ...
0
votes
1answer
182 views

Using REGEXP_REPLACE in Oracle

Am trying to use backreference expression to take out three subexpressions from a search, and reposition each subexpression as follows: SELECT REGEXP_REPLACE('AAA 123 ppp','(^[[:alpha:]]+) ([[:digit:...
5
votes
1answer
364 views

Postgres function index doesn't work correctly with regular expressions

I have this Postgres function. It forces text to be lowercase and all nulls to become empty strings, so that I more cleanly perform searches for things that don't match something, etc: CREATE OR ...
12
votes
1answer
8k views

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, ...
1
vote
2answers
90 views

How to Get the Second Sequence of Characters using Regular Expressions

I have a field with an address in it (ex. 68 TIDAL BREEZE DR) and this regular expression gets everything before the last sequence (ex. 68 TIDAL BREEZE): substring (address from '(.*) ') My question ...
1
vote
1answer
2k views

Select rows from my table where a character column matches a pattern

I'm using Postgres 9.5. I have a name column of type "character varying". I wonder how to select rows where the column begins with a number, followed by a space, followed by any other data. So I ...
3
votes
3answers
2k views

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 ...
1
vote
1answer
348 views

using regexp substitution part in postgres string functions

I hit this question trying to answer one in SO. When I pass \1 as first argument to lpad(string text, length int [, fill text]) function, it looks like it interprets \1 as regexp substitution part ...
1
vote
2answers
815 views

How to use character classes in a Postgres regex select?

I'm trying to create a query that selects strings that contain the number 21, without hitting strings such as 210 or 121. My efforts below have shown my progress, in that I've managed to apply a ...
1
vote
1answer
2k views

SSRS error - A scope is required for all aggregates in the page header or footer which reference fields

I had the following textbox expression in my SSRS report and it was working fine. = First(Fields!FirstName.Value) +" " + First(Fields!LastName.Value) + ", MD" When I moved the textbox to the ...
1
vote
2answers
479 views

How to Apply a Title-Case RegEx Condition for Object Names with Policy Based Management

I'm implementing PBM on a SQL Server 2014 instance and want to enforce a condition that all objects are created outside the dbo schema and all object names are created in title-case (i.e., OrderDetail)...
7
votes
2answers
6k views

Is there a T-SQL equivalent for punctuation as [0-9] is for numbers and [a-z] is for letters?

Is there a T-SQL equivalent of the [0-9] and [a-z] patterns that will let me pull values from a column that contains punctuation? For example: Create Table #Test ( Value VarChar(10) ) Insert Into ...
3
votes
1answer
80 views

Create a table based on a table depending on the values in the initial table column

I have a table like: +----+--------+----------------+ | id | name | address | +----+--------+----------------+ | 1 | Ivan | Moscow,Moscow | | 2 | Petr | Samara,Samara | | 3 | Grigor ...
0
votes
1answer
79 views

Help using regular expressions

I have two ORACLE tables. First table: ID l_name f_name belong_to 123 Smith John A Club 456 Jones Mary The Club, Your Club, My Club 789 Moore Sue The Club, A ...
1
vote
1answer
88 views

Using REGEX_LIKE to Implement a Check Constraint

Background I am working on the database design for an application that tracks information about database development projects at my company. The project management office (PMO) assigns a psued-...
4
votes
1answer
2k views

Can Postgres index regular expressions stored in a column?

I've got regular expressions stored as varchars in a column, which I need to match against incoming input. For example, the table might contain: | field | value | |-------|---------------| | ...
1
vote
2answers
6k views

Oracle regexp_like square brackets inside character set

This questions is in regards to Oracle, pl/sql, and the regexp_like function. I am trying to build a character set that will match on all typical special characters. My character set currently looks ...
0
votes
1answer
737 views

Extract four digits from a column by regexp

I am sitting on a database where one column contains two data types ;) Example "1";"When the Wind Blows 0275";"James Patterson " "4";"The Reluctant Fundamentalist 1026";"Mohsin Hamid"; The ...
1
vote
1answer
77 views

Pattern matching in PostgreSQL? [closed]

I have a string in which need to extract the date, Example: S01_XXX001_000_min_01_20150526T123440583.arc , S01_XXX001_000_20150526T123440583_min_01.arc based on the pattern like 'Numeric T Numeric',...
0
votes
2answers
3k views

Faulty oracle11g regexp_replace on removing duplicates

I have a comma separated list of values (as one single string), which contains duplicates, and I want to remove them. I tried with REGEXP_REPLACE but for certain values it gives me a wrong result: /* ...
2
votes
1answer
943 views

Order by where conditions

SELECT * FROM table WHERE key REGEXP 'some long regular expression' OR key REGEXP 'some other long regular expression' ORDER BY key REGEXP 'some long regular expression' DESC, key REGEXP 'some other ...
2
votes
1answer
117 views

How to store a 64-digit key of alpha numerical values into MySQL Database

I am student studying in Database Administration (first year), one of our task requires a to design a login form for corporate and regular users. Below are the requirements for the username and ...
0
votes
1answer
281 views

Mysql select using regexp

I have some user input i am receiving from some forms exactly in this format Names#Age#Gender#City The problem is,some forms come with incomplete data which is acceptable during the filling of the ...
1
vote
0answers
236 views

Import expanded csv file into mysql

I need to import a spreadsheet that was being viewed with the expand/collapse feature into mysql. As shown in the screenshot, when an item (WMIMCART1 in this case) is expanded, it shows more info ...
0
votes
2answers
5k views

Remove a character from a records enclosed between double quotes

I have a table in which every row have data like: 0150566115,"HEALTH 401K","IC,ON","ICON HEALTH 401K",,,1,08/21/2014 What I want is to remove every comma (,) that is enclosed between double quotes " ...
2
votes
1answer
606 views

How to apply a regex on a column fetched from DB

I am using IBM DB2. So, I am retrieving a column named SSN from a table. I have to apply the following regex on that column: ([1-57-8][0-9]{2} |0([1-9][0-9] |[0-9][1-9]) |6([0-57-9][0-9] |[0-9][0-57-...
1
vote
2answers
3k views

PostgreSQL get first letter of each word (except…)

I don't think I drank enough coffee today, but stuck on this for some reason. Trying to get the first letter of each word, except a few stopwords. Example "The United States of America" -> "USA" ...
0
votes
1answer
4k views

Assign result of regexp_split_to_array() to Pl/pgSQL array variable

How do I create an array and then put a result of a function into it? I'm doing it like this: array text[]; select regexp_split_to_array('whatever this is it splits into array with spaces', E'\\s+') ...
0
votes
2answers
2k views

Need help phrasing regular expression to find particular T-SQL pattern

I know this is a Database Forum, but since the text I am trying to find is SQL-specific, I am hoping that somebody can point me in the right direction. I need to search code to find places where the ...
0
votes
1answer
457 views

SELECT INTO with regexp_replace() doesn't write changes into newly generated table

I have been using this query in Postgres 9.1 in order to remove '' from existing data. Below is a sample of the data before running regexp_replace(): 6'' 6'' 6'' 20'' 12'' 18'' 20'' 8'' 10'' '' '' ...
0
votes
1answer
1k views

MYSQL REGEXP for text not between parentheses

I'm looking to search a large MYSQL table for a string and only return results that aren't between parentheses. If my table looks like this: | ID |Data | | 1 |Some search ...
1
vote
3answers
211 views

How to map similar camelcased, pascalcased, underscored, lowerscored words to the same id?

I'm working on PostgreSQL and I have a table like this called words_table: I need all equivalent words (like software_design and software-design) to have its map value = to its word's equivalent ...
2
votes
1answer
6k views

MySQL Regex matching newline or end of string

I have a text column in mysql which contains some values separated by a newline. I want now to query by these values and thought a regex should help me with that by doing something like: SELECT * ...
0
votes
1answer
157 views

Use regex in postgres

I want to use regexp_replace() to replace the string name1-01.name2-02.1 to name1.01-name2.02.1 How to use the regex here?
1
vote
0answers
338 views

Regular Expression Integrity Constraints in SQLite3

In a SQLite3 CREATE TABLE statement, can I use a regular expression to enforce a particular constraint? Specifically, I am trying to require that an inputted URL is valid. I know there are other ways ...
13
votes
2answers
40k views

How to use SUBSTRING using REGEXP in MySQL

I have the following situation. I have to substring regular expression from description using MySQL. Description: Lorem D9801 ipsum dolor sit amet Where D9801 is REGEXP. Every strong text ...
0
votes
1answer
3k views

RegEx bug in MongoDB

I run the following queries on a collection that have a lot of entries that contain [ and ]. db.test.find({word:/[\[]/}); // could not be run in console db.test.find({word:/\[/ }); ...
2
votes
2answers
111 views

Regular Expression Difficulty

I'm trying to extract 456 from the string :123:456: as follows: select regexp_substr(':123:456:', ':(\d+):', 1, 2, 'i', 1) from dual However, this query returns null. What am I doing wrong?
0
votes
1answer
166 views

Regular expression problem

SELECT FIRSTNAME,LASTNAME, EMAIL FROM CUSTOMERS WHERE REGEXP_LIKE(EMAIL,'[A-Z0-9._%-]{1,10}@[a-z0-9._%-]{1,5}\.[net|com]','i'); I know this is not practical or make a ton of sense, but its a ...
90
votes
8answers
123k views

Pattern matching with LIKE, SIMILAR TO or regular expressions in PostgreSQL

I had to write a simple query where I go looking for people's name that start with a B or a D : SELECT s.name FROM spelers s WHERE s.name LIKE 'B%' OR s.name LIKE 'D%' ORDER BY 1 I was wondering ...
1
vote
1answer
883 views

sp_OACreate vbscript.regexp Class not registered

Imagine a Windows Server 2003 Enterprise x64 Edition. I can create a 'vbscript.regexp' object using a vbscript (confirming that the DLL is registered). I cannot create a 'vbscript.regexp' object ...