Split

Divide the contents of a variable into 2 parts and place each part into a separate variable. (This is often called parsing in computer-speak.)

You can choose to split the variable:

  • At the occurrence of a specific character (called a delimiter); or

  • At a numbered location within the variable (i.e., by character position)

  1. Enter the name of the variable you want to split

  2. Enter the delimiter or numbered character position at which you want to split the variable (can include free text and/or values copied from different variables)

  3. Enter the names of the variables into which you'd like to place the 2 parts of the original variable

  4. Indicate if you want to remove any blank spaces at the beginning and end of these variables (includes: <Space> <Tab> and <Enter>)

How exactly is the variable split?

  • Delimiter

    • 1st variable = the part of the original variable preceding the delimiter

    • 2nd variable = the part of the original variable following the delimiter

    • The delimiter is erased

  • Character position:

    • 1st variable = the part of the original variable up to and including the character position specified

    • 2nd variable = the part of the original variable following the delimiter

    • Spaces are included when counting character position

Using SPLIT in combination with LOOP

SPLIT is one of the many advanced commands that is often used in combination with Loop. When using SPLIT within a loop, it is often useful to split the original variable as follows:

  1. Place one of the parts into a new variable

  2. Overwrite the "pre-split" value of the original variable with the "post-split" value

Learn more about the Loop command

Example

Extracting information from a long text file

Let's say you have all the text from a new employee's CV stored in a variable named cv text. You'd like to extract only the necessary details and input them into your HR system. To start, extract the employee's name as follows:

  1. Place everything prior to the employee name into a variable named trash. Keep the employee name and everything following it in cv text.

    cv text =

    1234 Main Street; Independence,

    Missouri 64052; Home – (816) 555-1234;

    Mobile – (816) 444-5678; Name: Harry

    S. Truman; Position sought: POTUS;

    Prior Experience: Senator, Vice

    President; Favorite expression: The

    buck stops here.

    Result:

    trash =

    1234 Main Street; Independence,

    Missouri 64052; Home – (816) 555-1234;

    Mobile – (816) 444-5678;

    cv text =

    Harry S. Truman; Position sought:

    POTUS; Prior Experience: Senator, Vice

    President; Favorite expression: The

    buck stops here.

  2. Place the employee name into a variable named ename and everything after it into trash.

    Result:

    ename =

    Harry S. Truman

    trash =

    Position sought: POTUS; Prior

    Experience: Senator, Vice President;

    Favorite expression: The buck stops here.