CallFire/callfire-ivr-samples — pull request #6 by spisakfire (2013-10-28 20:19:56+00:00)
Title: Update SplitJoin.xml

'.split()' breaks apart the string at the spot described in the argument. For example, '.split("")' says to break apart the string between every element; '.split("|")' says to break it apart every time it reaches the "pipe" character ( | ); '.split(",")' says to break it apart every time it reaches a comma.

'.join()' puts the string back together with whatever character is indicated by the argument inserted between the previously split elements. For example, '.join("|")' puts the string back together with the "pipe" as a delimiter.

'.join(" ")' puts the string back with a space between the elements. This is used to "explode" a number for correct text-to-speech playback.

The semicolon ';' is used to end a Java command.

For example, to "explode" a number for correct TTS playback, we would need to split each element (number) in the string and insert a space between them. Assuming our "number" is the variable 'acctNum', our tag would look like this:

${acctNum}.split("").join(" ");

Suppose we sent an account ID using a get tag, and got back a variable ('myResult') that contained three elements — the user name, account balance, and due date — separated by a 'pipe' ( | ) delimiter. We could take the results of the Get Tag ('myResult') and split it into the three elements at the pipe delimiter, and place each element into its own variable:

${myResult}.split("|")[0];
${myResult}.split("|")[1];
${myResult}.split("|")[2];