Removing all the vowels from a string - PL/SQL

oracle, plsql, sql

Solution

Technically, the assignment calls for an anonymous pl/sql block, and prompting user for input. So you'd have something like this:

set serveroutput on
set verify off

accept vstring prompt "Please enter your string: ";
declare
   vnewstring varchar2(100);
begin
   vnewstring := regexp_replace('&vstring', '[aeiouAEIOU]','');
   dbms_output.put_line('The new string is: ' || vnewstring);
end;
/

You can put this in a file called "my_homework_from_SO.sql" and from the same directory the file is located, login to sqlplus and run it:

@my_homework_from_SO.sql

Please enter your string: This is a test
The new string is: Ths s  tst

PL/SQL procedure successfully completed.

Problem

I have this homework assignment : ``` Write an anonymous PL/SQL block that accepts a string as input and removes all of the vowels (a.e.i.o.u) from the string, then outputs the results. The output should look like this: Run the Program SQL>@rm_vowels Enter the String: A penny for your thoughts SQL>**************************** SQL>The new string is: pnny fr yr thghts ``` And this does look like something really easy to do but I'm really lacking some PL/SQL experience to get this done. From my searches so far I've realized I need to use something similar to this : ``` REGEXP_REPLACE(name,'[a,e,i,o,u,A,E,I,O,U]','') ``` Right ?

Original source