Some options:
SQL Fiddle
Oracle 11g R2 Schema Setup: Some test data with 1 character per row:
CREATE TABLE table1 ( a ) AS
SELECT SUBSTR( value, LEVEL, 1 )
FROM (
SELECT '&*,.:;`~¿ÄÅÇÉÑÖÜßàáâäåçèéêëìíîïñòóôöùúûüÿƒα'
|| 'abcdefghijklmnopqrstuvwxyz'
|| 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|| '0123456789' AS value
FROM DUAL
)
CONNECT BY LEVEL <= LENGTH( value );
Query 1:
Naively, if you want to just match specific characters then you can just enumerate all the characters you want to match in a regular expression:
'[&*,.:;`~¿ÄÅÇÉÑÖÜßàáâäåçèéêëìíîïñòóôöùúûüÿƒα]'
For example - this lists all the matched characters (aggregated into a single row for compactness):
SELECT LISTAGG( a, '' ) WITHIN GROUP ( ORDER BY ROWNUM ) AS matches
FROM table1
WHERE REGEXP_LIKE( a, '[&*,.:;`~¿ÄÅÇÉÑÖÜßàáâäåçèéêëìíîïñòóôöùúûüÿƒα]' )
Results:
| MATCHES |
|---------------------------------------------|
| &*,.:;`~¿ÄÅÇÉÑÖÜßàáâäåçèéêëìíîïñòóôöùúûüÿƒα |
Query 2:
If you know the characters you do not want to match then you can negate the pattern [^characters to not match]
to find out whether there are any other characters:
For example:
SELECT LISTAGG( a, '' ) WITHIN GROUP ( ORDER BY ROWNUM ) AS matches
FROM table1
WHERE REGEXP_LIKE( a, '[^a-z0-9, ]', 'i' )
Results:
| MATCHES |
|--------------------------------------------|
| &*.:;`~¿ÄÅÇÉÑÖÜßàáâäåçèéêëìíîïñòóôöùúûüÿƒα |
Query 3:
If you do not have a simple expression you can negate but, instead, want to match characters that are equivalent to base letters then you can use [=a=]
to match a
, à
, á
, â
, ä
or å
and would give a regular expression like:
[[:punct:][=a=][=c=][=e=][=i=][=n=][=o=][=u=][=y=]α߃]
For example:
SELECT LISTAGG( a, '' ) WITHIN GROUP ( ORDER BY ROWNUM ) AS matches
FROM table1
WHERE REGEXP_LIKE( a, '[[:punct:][=a=][=c=][=e=][=i=][=n=][=o=][=u=][=y=]α߃]', 'i' )
Results:
| MATCHES |
|-------------------------------------------------------------|
| &*,.:;`~¿ÄÅÇÉÑÖÜßàáâäåçèéêëìíîïñòóôöùúûüÿƒαaceinouyACEINOUY |
Query 4:
But that also matches the base characters, so we could negate the previous match and use REGEXP_REPLACE
to strip out the non-matching characters and then test for the existence of a non-base character:
SELECT LISTAGG( a, '' ) WITHIN GROUP ( ORDER BY ROWNUM ) AS matches
FROM table1
WHERE REGEXP_LIKE(
REGEXP_REPLACE(
a,
'[^[:punct:][=a=][=c=][=e=][=i=][=n=][=o=][=u=][=y=]α߃]'
),
'[^a-z]',
'i'
)
Results:
| MATCHES |
|---------------------------------------------|
| &*,.:;`~¿ÄÅÇÉÑÖÜßàáâäåçèéêëìíîïñòóôöùúûüÿƒα |