Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle query to find string not containing characters

What is an Oracle query that will return all records where the field mytable.myname contains any characters other than

  1. A-Z
  2. a-z
  3. 0-9
  4. -/\()
like image 482
Marcus Leon Avatar asked Sep 06 '25 03:09

Marcus Leon


1 Answers

You can use the following:

SELECT * FROM mytable WHERE REGEXP_LIKE (myname, '^[^a-zA-Z0-9\/\\()-]+$');

You can also do the same with an i modifier:

SELECT * FROM mytable WHERE REGEXP_LIKE (myname, '^[^a-z0-9\/\\()-]+$', 'i');

Explanation:

  • ^ start of the string
  • [^___ ] negative character set (which will match any character other than the characters specified inside it)
  • + match the previous group more than once
  • $ end of the string
like image 67
karthik manchala Avatar answered Sep 09 '25 02:09

karthik manchala