Lesson Summary

As with numerical calculations, functions can also be used to manipulate text strings in a number of ways. We discussed the concatenation function earlier in this guide, but you now know that there is a wider range of text-specific functions. Using these functions, you can strip unnecessary information out of text, connect two or more pieces of text together to form concatenated strings, and much more:

  • Strlen - Evaluates a single value as a string, returning the number of total characters (including blank spaces) in the string.
  • Substr - Given a string, a start position and a number of characters, returns a smaller string which begins at the start position of the original string, and contains the number of characters specified. If the specified length exceeds the remaining length of the original string, the substring cuts off with the original string’s final character.
  • Chr - Given a string an index value, returns the character of the string located at the specified index.
  • Trim - Removes all whitespace from both sides of the supplied string.
  • LTrim and RTrim - Removes whitespace from the left or the right side of the supplied string, respectively.

Whenever you use a numeric value in a string function, that value will be treated as text. For example, the number 30 will be interpreted as “30” for the purpose of a string function. Any numeric functions nested within string functions will have their calculated values converted into text, which will then be evaluated as part of the string function.

 

<< Previous: Evaluating Numeric Data as Strings | Next: Test Your Knowledge! >>