Hi ALL,
I need to test or check a string for alphanumeric values i.e only alphabets either A to Z in capitals or a to z in small letters and number 0 to 9 are allowed
except these no other values are allowed or others values are not allowed.
Oracle DataBase Version : 11.2.0.4.0.
my test cases.
--------------------
--Both AplhaNumeric
-----------------------
SELECT REGEXP_INSTR('!@!@!@','^[a-zA-Z0-9]+$') FROM DUAL; --Results 0 is correct because of special chracters.
Output
------
0
--Results 1 which is incorrect because only number and no alphabets are present in the string , it should be retrun 0
SELECT REGEXP_INSTR('213123213','^[a-zA-Z0-9]+$') FROM DUAL;
Output
------
1
--Results 1 which is incorrect because only alphabets and no numbers are present in the string , it should be retrun 0
SELECT REGEXP_INSTR('asdsadasd','^[a-zA-Z0-9]+$') FROM DUAL;
Output
------
1
--Is Correct because these string contains alphanumeric
SELECT REGEXP_INSTR('asdsadasd213123','^[a-zA-Z0-9]+$') FROM DUAL;
Output
------
1
--Same wrong result in these sql also
SELECT LENGTH(TRIM(TRANSLATE('weasdasd123213213', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', ' '))) FROM DUAL;
SELECT REGEXP_INSTR('wqeqwewqe','^[[:alnum:]]+$') FROM DUAL;
SELECT REGEXP_INSTR('dsada213123','[a-zA-Z0-9]*') FROM DUAL;
SELECT COUNT(*) FROM DUAL WHERE REGEXP_LIKE('123123asdasd','^[a-zA-Z0-9]*$');
Any help is appreciated.