LEFT, MID and RIGHT String operators

Strings can use three special functions. They are referred to as operators but in truth they are functions which can be applied to strings.

LENGTH(TEXT)

This will return the size (the number of characters) of the text passed through.

  1. LENGTH("hello") returns 5
  2. LENGTH("bert") returns 4

LEFT (TEXT, LEN)

This will return the first few characters in a string. The string is passed in through the first parameter and the number of letters is passed through the second parameter. The following example calls will show how it is used -

  1. LEFT("hello", 2) returns "he"
  2. LEFT("bert",3) returns "ber"
  3. LEFT("poppy", 1) returns "p"
  4. LEFT("sue",3) returns "sue"

RIGHT(TEXT, LEN)

This will do the exact same as LEFT(TEXT,LEN) only it will start from the right. In this case it will take the first parameter as the text to process and the second parameter as the number of letters to read in from the right. Some example calls -

  1. RIGHT("hello", 2) returns "lo"
  2. RIGHT("bert",3) returns "ert"
  3. RIGHT("poppy", 1) returns "y"
  4. RIGHT("sue",3) returns "sue"

MID(TEXT,START,LEN)

MID will, potentially, get the middle values. The first parameter is the string to process. The second parameter is the start position. If you index each letter then the start will represent the index of the first letter you want to obtain. The third parameter says how many letters to get. LEFT and RIGHT can be represented by MID.

Some example calls-

  1. MID("hello", 2, 2) returns "el"
  2. MID("bert",2, 3) returns "ert"
  3. MID("poppy", 2, 1) returns "o"
  4. MID("sue", 0, 3) returns "sue"