# Numbers & Text > Text

## Conversion

### Convert to Text

Converts the given value to text.

``("" + [VALUE])``

## Constants

### Empty Text

Returns an empty text ("").

``""``

### Space

Returns a space (" ").

``" "``

## Operations

### Text Length

Returns the number of characters in the given text.

``[TEXT].length``

### Combine Text

Combines the two given pieces of text into one and returns that result.

``[TEXT] + [TEXT]``

### Trim Text

Removes spaces from the beginning and the end of the given text and returns that result. (When given an attribute, the value of the attribute remains unchanged.)

``StringTools.trim([TEXT])``

## Comparison

### Equals (Text)

Returns `true` if both pieces of text are exactly the same.

``([TEXT] == [TEXT])``

### Is Text Empty?

Returns `true` if the length of the given text is 0.

``([TEXT] == "")``

### Does Text come before/after?

Returns `true` if the first given text alphabetically comes before (or after) the second given text.

``````//A comes BEFORE B
strCompare([TEXT], [TEXT], -1);

//A comes AFTER B
strCompare([TEXT], [TEXT], 1);``````

## Find / Replace

### Find Character

Returns the character at the given position. Note that the first index in a text is 0, not 1. Throws a runtime error if the given position is out of bounds.

``[TEXT].charAt([INT])``

### Get Text Position

Returns the index at which the given phrase (or character) appears in the given text. Returns -1 if the phrase is not found.

Example: The word "dog" corresponds to these indices: d = 0, o = 1 and g = 2. If you selected the letters "og" from the word "dog" (enter "og" in the field on the left and "dog" in the field on the right), the result would be 1.

``[TEXT].indexOf([TEXT])``

### Replace Text in Text

Replaces one phrase with another within the given text.

Example:

Returns `cheeseburger`

``StringTools.replace([TEXT], [TEXT], [TEXT])``

### Substring (Part of Text)

Returns part of the given text, given the starting and ending indices. More specifically, this block returns the characters beginning with the start index and ending with one less than the ending index.

Example: The word "cats" corresponds to these indices: c = 0, a = 1, t = 2, s = 3. If you enter "cats" in the field on the left, and 1, 3 as your starting and ending index numbers, the block would return the letters "at", i.e. the letters that correspond to the index numbers 1 and 2 in the word "cats."

``[TEXT].substring([INT], [INT])``

## Case

### Get Text in Upper/Lower Case

Returns the given text in all uppercase (or lowercase).

``````[TEXT].toUpperCase()
[TEXT].toLowerCase()``````

## Split

### Split into Words

Splits the given text up into a list, using space as the separator (delimiter).

``[TEXT].split(" ")``

### Split using Separator

Splits the given text up into a list, using the given separator (delimiter) text.

``[TEXT].split([TEXT])``

## Fonts

### Get Width of Text using Font

Returns the width of the given text using the given font. Useful for calculating positions for drawing text.

``[FONT].font.getTextWidth([TEXT], [FONT].letterSpacing)/Engine.SCALE``

### Get Height of Font

Returns the height of the given font. Useful for calculating positions for drawing text.

``[FONT].getHeight()/Engine.SCALE``