Find out Vowels in a String in Oracle

We can find out the number of Vowels in a string by using normal string functions in Oracle.
Suppose India Is My Country is the string .


SELECT length('India Is My Country')-

length(
REPLACE(translate('India Is My Country','aeiouAEIOU','          '),' '))FROM dual.

The logic behind is just subtract the length of non-vowel characters from length of whole string. Translate command will translate the occurrence of vowels into space. Now the string does not contain any vowels. Now remove all spaces from the string .Now you have a string which does not have vowels or space. Remove length of this string from total length. This is the number of vowels in the given string

Comments

Popular posts from this blog

Introduction To Oracle10g

Insert

Except