SPLIT: Extracting an Element From a String

How to:

The SPLIT function returns a specific type of element from a string. The output is returned as variable length alphanumeric.

Syntax: How to Extract an Element From a String

SPLIT(element, string)

where:

element

Can be one of the following keywords:

  • EMAIL_DOMAIN. Is the domain name portion of an email address in the string.
  • EMAIL_USERID. Is the user ID portion of an email address in the string.
  • URL_PROTOCOL. Is the URL protocol for a URL in the string.
  • URL_HOST. Is the host name of the URL in the string.
  • URL_PORT. Is the port number of the URL in the string.
  • URL_PATH. Is the URL path for a URL in the string.
  • NAME_FIRST. Is the first token (group of characters) in the string. Tokens are delimited by blanks.
  • NAME_LAST. Is the last token (group of characters) in the string. Tokens are delimited by blanks.
string

Alphanumeric

Is the string from which the element will be extracted.

Example: Extracting an Element From a String

The following request defines strings and extracts elements from them.

DEFINE FILE WF_RETAIL_LITE
STRING1/A50 WITH COUNTRY_NAME= 'http://www.informationbuilders.com';
STRING2/A20 = 'user1@ibi.com';
STRING3/A20 = 'Louisa May Alcott';
Protocol/A20 = SPLIT(URL_PROTOCOL, STRING1);
Path/A50 = SPLIT(URL_PATH, STRING1);
Domain/A20 = SPLIT(EMAIL_DOMAIN, STRING2);
User/A20 =  SPLIT(EMAIL_USERID, STRING2);
First/A10 = SPLIT(NAME_FIRST, STRING3);
Last/A10 = SPLIT(NAME_LAST, STRING3);
END
TABLE FILE WF_RETAIL_LITE
SUM Protocol Path User Domain First Last
ON TABLE SET PAGE NOLEAD
END

The output is shown in the following image.