Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle SQL - REGEXP_LIKE contains characters other than a-z or A-Z

Tags:

regex

sql

oracle

I would like to create a query where I select all records which contain characters that are not a-z or A-Z

so something like this

SELECT * FROM mytable WHERE REGEXP_LIKE(column_1, '![A-Z] [a-z]')

like image 483
Tom Avatar asked Mar 07 '12 15:03

Tom


People also ask

What does REGEXP_LIKE return?

The REGEXP_LIKE scalar function returns a boolean value indicating if the regular expression pattern is found in a string. The function can be used only where a predicate is supported. The schema is SYSIBM. An expression that specifies the string in which the search is to take place.

What is the syntax of REGEXP_LIKE condition in Oracle Plsql?

Example - Match on end Next, let's use the REGEXP_LIKE condition to match on the end of a string. For example: SELECT last_name FROM contacts WHERE REGEXP_LIKE (last_name, '(*)n$'); This REGEXP_LIKE example will return all contacts whose last_name ends with 'n'.

How do I find a particular character in a string in Oracle?

The Oracle INSTR function is used to search string for substring and find the location of the substring in the string. If a substring that is equal to substring is found, then the function returns an integer indicating the position of the first character of this substring.

Can we use regex in Oracle SQL?

Oracle Database Implementation of Regular ExpressionsYou can use these functions in any environment that supports Oracle Database SQL. You can use these functions on a text literal, bind variable, or any column that holds character data such as CHAR , NCHAR , CLOB , NCLOB , NVARCHAR2 , and VARCHAR2 (but not LONG ).


1 Answers

The ^ negates a character class:

SELECT * FROM mytable WHERE REGEXP_LIKE(column_1, '[^A-Za-z]') 
like image 96
Michael Berkowski Avatar answered Oct 01 '22 10:10

Michael Berkowski