Why is '1A' not considered in alphanumeric class?
SELECT 'yes'
FROM dual
WHERE REGEXP_LIKE('1A', '[:alnum:]');
Why is '1A' not considered in alphanumeric class?
SELECT 'yes'
FROM dual
WHERE REGEXP_LIKE('1A', '[:alnum:]');
Copyright © 2021 Jogjafile Inc.
A pair of unescaped
[...]creates a bracket expression. POSIX character classes, like[:alpha:],[:alnum:], can only be declared inside a bracket expression.Use the POSIX character class inside a bracket expression:
See an online demo.
Note that when you use
'[:alnum:]', the regex engine parses it as a regular bracket expression matching any characters/character ranges defined inside the bracket expression. I.e. the[:alnum:]regex matches any single char that is either:,a,l,n,uorm. Since your input hasa(1a) the regex engine returns a valid match once it encountersain the input.