Finding the count of characters and numbers in a string
@alfasin answer is good, but if you're using 11g then it can get simpler:
select name,
REGEXP_count(name,'\d') as num_count,
REGEXP_count(name,'[a-zA-Z]') as char_count,
from test6;
If I understand correctly you are using Oracle PLSQL, and as far as I know, there isn't any "built-in" method (in PLSQL) that counts the number of digits/characters in a string.
But, you can do the following to count characters:
select LENGTH(REGEXP_REPLACE('abcd12345','[0-9]')) from dual
and digits:
select LENGTH(REGEXP_REPLACE('abcd12345','[a-zA-Z]')) from dual
Or, in your case:
select name,
LENGTH(REGEXP_REPLACE(name,'[a-zA-Z]','')) as num_count,
LENGTH(REGEXP_REPLACE(name,'[0-9]','')) as char_count,
from test6;
For Bill the Lizard:
My answer was tested on Oracle 11g and it works just fine!
If you decide to delete my answer again, please be kind enough to add a comment that explains why. I was also looking for you in the chat rooms...