54.2 GET_INITIALS Function

Returns the initials of the words in a string. Splits the string into words and takes the first letter of each word. If there is only one word, then it takes the first p_cnt letters.

Syntax

APEX_STRING.GET_INITIALS (
   p_str IN VARCHAR2,
   p_cnt IN NUMBER DEFAULT 2 )
   RETURN VARCHAR2

Parameters

Parameters Description
p_string The input string.
p_cnt The maximum length of the initials to return. The default is 2.

Example

Get initials from "John Doe".

begin
  sys.dbms_output.put_line(apex_string.get_initials('John Doe'));   
end; 
-> JD

begin
  sys.dbms_output.put_line(apex_string.get_initials(p_str => 'Andres Homero Lozano Garza', p_cnt => 3));
end;
-> AHL