I want my regular expression should error out if my string contains any character other than Alphanumeric. The string should error out if there is a new line character or any white space character in between the string or at the end or at the beginning. I am using below code -
SELECT CASE WHEN NOT REGEXP_LIKE(MYSTRING, '^[a-zA-Z0-9]*$') THEN 'invalid'
ELSE 'valid'
END
FROM DUAL
this works when
MYSTRING in ('ABCD ',' ABCD', 'ab cd','ab+cd')
But it does not work when there is new line char at the end of the string
MYSTRING = 'ABCD'||chr(10);
I want it should error out when there is any char other than alphanumeric. Please advise. Thanks in advance.

'\A[a-zA-Z0-9]*\z're,\zis not supported,\Zis used instead, BUT in PCRE regex flavor,\Zmatches the end of text but also any position before trailing newline(s). So, we are lucky here that this flavor supports the PCRE construct.