Match variable length of string with hyphen , not with underscore and not German special character in oracle REGEXP_LIKE

Viewed 24

I want to match a string which start with char (A-Z) and can have up to 6 word and 2 number like: ABD00, ABCDEFG12, A-SDS12, DXSDV1-12,

but I don't want string which have underscore "_" or any German special character like "äöüßÄÖÜ" So word which i want restrict is like: AAA_AAA12, A_14, AAAAAAAA09, AÖAAAAA09

-- wokring
select 1 from dual where REGEXP_LIKE ('AAUT-PI09', '^[A-Z]\w{1,6}|-{1,6}\d{2}');
-- not working
select 1 from dual where REGEXP_LIKE ('A-AUTPI09', '^[A-Z]\w{1,6}|-{1,6}\d{2}');

-- working
select 1 from dual where REGEXP_LIKE ('AAAAAß09', '^[A-Z]\w[^_|^ä|^ö|^ü|^ß|^Ä|^Ö|^Ü]{1,6}\d{2}');
-- but should not work for
select 1 from dual where REGEXP_LIKE ('AAAAAAAA09', '^[A-Z]\w[^_|^ä|^ö|^ü|^ß|^Ä|^Ö|^Ü]{1,6}\d{2}');

-- work for below
select 1 from dual where REGEXP_LIKE ('AA_AAAA09', '^[A-Z]\w[^_|^ä|^ö|^ü|^ß|^Ä|^Ö|^Ü]{1,6}\d{2}$');
-- but should not work for 
select 1 from dual where REGEXP_LIKE ('A_AAAAA09', '^[A-Z]\w[^_|^ä|^ö|^ü|^ß|^Ä|^Ö|^Ü]{1,6}\d{2}$');

and how to restrict German special character and underscore "_" from 2 to 6 position in string?

0 Answers
Related