Logo Text Blaze
  • Products
    • Text Blaze
      Snippets and templates
    • AI Blaze
      AI writing and editing
    • Data Blaze
      Tables and sheets
    Downloads
    • Add to Chrome
    • Windows app
    • MacOS app
  • By function
    • Support & operations
    • Sales
    • Healthcare
    • Education
    • Recruiting
    • Marketing
    Business
    • For teams
  • Resources
    • Documentation
    • Community forum
    • Gallery
    • Contact us
  • Pricing

Documentation

No search results

Text Blaze

Loading...

Data Blaze

Loading...

Community Forums

Loading...
Add to Chrome –  It's Free! Go to Dashboard ›
Docs > Reference
  • Guides
    • Quick Start
    • Sharing Snippet Folders
    • Dynamic Commands
    • Date and Time
    • Autopilot
    • Forms
    • Formulas
    • Rules & Validation
    • Tables in Snippets
    • Connect Other Apps
    • Tidying Whitespace
    • Lists
    • Read Data from Websites
    • Teams and Organizations
  • Tutorial Videos
  • Gallery
  • Frequently Asked Questions
  • Formula Reference
  • Dynamic Commands
    • Using Dynamic Commands
    • {=} (Formula Command)
    • {button}
    • {click}
    • {clipboard}
    • {cursor}
    • {error}
    • {formdate}
    • {formmenu}
    • {formparagraph}
    • {formtext}
    • {formtoggle}
    • {if}
    • {import}
    • {key}
    • {link}
    • {note}
    • {repeat}
    • {run}
    • {site}
    • {snippet}
    • {time}
    • {user}
    • {wait}
  • Connected Snippets
    • Connected Snippets Overview
    • {image}
    • {urlload}
    • {urlsend}
    • {dbselect}
    • {dbinsert}
    • {dbupdate}
    • {dbdelete}
  • Command Packs
    • Capitalize
    • Gmail
    • LinkedIn
    • Randomize

What's on this Page

  • Supported Values
  • Creating Variables
  • Lists
    • Ordered Lists
      • Accessing Items In Ordered Lists
    • Keyed Lists
      • Accessing Items In Keyed Lists
  • Functions
    • Function as an argument
    • Functions as command settings
    • Assign a function to a variable
  • Supported Operators
    • Math Operators
    • Comparison Operators
    • String Operators
    • Logical Operators
  • Built-in Functions
    • Math Functions
    • Trigonometric Functions
    • Statistical Functions
    • Error Functions
    • Text String Functions
    • Regular Expression Functions
      • Supported flags
    • Date Time Functions
    • List Functions
    • Ordered List Functions
    • Keyed List Functions
    • Information Functions
    • Data Encoding Functions
    • JSON Functions
  • Escaping Special Characters
  • Special Delimiters
  • List Comprehensions
    • List Comprehensions with Keyed Lists
  • Multi-line formulas
  • Variable scopes
  • Regular Expressions
    • Using simple patterns
    • Using special characters
    • Special characters in regular expressions
  • More Regular Expression Examples
  • Next Steps
Reference

Formula Reference

The Blaze Formula Language makes it possible to use formulas and calculations as part of your snippets.

This enables dynamic snippet content.

The Blaze Formula Language is used in the {=} (Formula Command), {if} and {repeat} commands.

There's a lot of functionality built-in to help you truly make snippets your own.

This page will cover everything you need to know about the Blaze Formula Language and includes a variety of examples.

Blaze Formula Language
Copy to Text Blaze

Count: 

default23namecount



50% More Would Be: 

=
count * 1.5




if
count > 10
That's a lot!
else

Not so many.


Snippet preview

Supported Values

The Blaze Formula Language supports five types of values:

  1. Numbers (e.g. 12, 3.75, or -10)
  2. Booleans (yes or no)
  3. Text Strings (e.g "abc" or "this is a string")
  4. Lists (e.g. [1, 2, "three", yes])
  5. Functions (e.g. (x) -> x * 2)

Throughout this documentation page, you'll learn that the Blaze Formula Language primarily consists of working with and manipulating these core supported values.

Text Blaze will convert between these different types as needed. For example, let's look at the max() function which takes two or more numbers and returns the largest one of them. If you pass a string to the max() function, it will attempt to convert the string to a number automatically. For example, max(2, "3", 1) would return the number 3.

You'll learn about those, but before that, we'll review a very important concept within your snippets: Creating Variables.

Creating Variables

Text Blaze allows you to create variables to reference values in your snippets. There are several ways to create variables in your snippets:

  1. The {=} (Formula Command) command provides an assignment mode that allows you to create a variable.
  2. Forms commands allows you to use the name setting to explicitly give a form value a variable name.
Working with variables
Copy to Text Blaze



num =
12




bool =
yes




str =
"this is a string"




`Multi word variable name` =
"variable names can be multiple words"




defaultJohnnamefirstname


num: 

=
num


firstname: 

=
firstname


str: 

=
str


bool: 

=
bool


Multi word variable names: 

=
`multi word variable name`


Snippet preview

Variable names are case-insenstive, so "address" and "Address" refer to the same thing. Regular variable names start with a letter which is followed by any combination of letters, numbers and underscores. You can create variable names that include spaces or other special characters, however you must enclose those variable names in back ticks ` when referencing them in your formulas.

Creating variables and saving data becomes important as you use the various features of the Blaze Formula Language.

Lists

Lists are a value type that can hold more than one value at a time. They are wrapped in brackets ([]) with each value being separated by a comma (,).

There are two types of lists in Text Blaze: ordered lists and keyed lists.

Ordered Lists

Ordered lists are a set of one or more values.

For example, ["Hi"] or ["Hi", "Hello", ...]. A list can also be empty and contain no values (e.g. []).

A list can contain values of any type (e.g. [1, 2, "three", yes]), but the most common use case is multiple values of the same type (e.g. ["Katie", "John", "Greg"]).

Accessing Items In Ordered Lists

Since there is a distinct order to the items in the list, you can access a specific item by its index using the syntax list[index].

An index is the position of the element in the list. The first element in the list has index 1, the second index 2 and so on. For example:

Ordered Lists
Copy to Text Blaze



=
["I'm index 1", 2, 3, "#4"][1]




=
["I'm index 1", 2, 3, "#4"][2]




=
["I'm index 1", 2, 3, "#4"][4]


Snippet preview

Ordered lists are especially useful when processing multiple items of a specific type.

Keyed Lists

Keyed lists, the second type of list, are a set of key-value pairings. Their syntax is as follows:

["key a": ValueA, "key b": ValueB, ...]

Keys are case-sensitive.

Also, unlike ordered lists, there is no ordering to the keys or values in keyed lists.

Accessing Items In Keyed Lists

You can access individual elements using the syntax list.key. For example:

Keyed Lists with . syntax
Copy to Text Blaze



=
["color": "red", "age": 33, "sign": "libra"].color




=
["color": "red", "age": 33, "sign": "libra"].age


Snippet preview

The "." syntax to reference a value in a keyed list doesn't work when the key has spaces or other special characters in it.

To access values in this case you can use the ["key a"] syntax. You can also use this syntax to reference values that don't contain any spaces or special characters, similar to the "." syntax (e.g. ["color"]).

While this syntax may look similar to the way values are referenced in ordered lists, notice how a string is used instead of a number because you're not referencing a position in the list.

Keyed Lists with bracket syntax
Copy to Text Blaze



=
["color": "red", "age": 33, "sign": "libra", "favorite food": "pizza"]["favorite food"]




=
["color": "red", "age": 33, "sign": "libra", "favorite food": "pizza"]["color"]


Snippet preview

If the key is not quoted when defining a list, it is a treated as a variable and the value of the variable is used as the key value. The following example illustrates this:

Variables as Keys
Copy to Text Blaze
Snippet preview

Later on this documentation page, you'll learn about a variety of useful built-in functions that work on lists.


Functions

A function is similar to a built-in function except it does not have a name.

The syntax for a function is:

(arg1, arg2, ...) -> doSomething(arg1, arg2, ...)

A function is treated as a value in Text Blaze. This means three things:

  1. Built-in functions can take functions as an argument, just like a Number, Text String, or any other value.
  2. Some command settings can receive a function as a value.
  3. You can assign a function to a variable using the {=} (Formula Command) command's assignment mode.

Function as an argument

The filter() function, which allows you to filter a list takes a function to define the filtering to use. The function must return a Boolean.

The following example shows the use of functions with the filter() built-in function to filter the same ordered list in three different ways:

Using a function as the argument, you can define whatever filtering method you want. Also, notice how it's possible to use built-in functions in your functions.

Functions as command settings

A function can be used as a command setting's value. For example, {formmenu} has a setting called itemformatter that allows you to format the individual values of the menu items before snippet insertion.

Visit the {formmenu} command to learn more about its functionality.

Assign a function to a variable

Using the {=} (Formula Command)'s assignment mode, it's possible to assign a function to a variable.

Here's an example for squaring a number:

Notice how in the example above, we're creating a function and using other built-in functions within it. Functions allow you to combine operators, built-in functions, and even other functions inside of them.

Finally, we're saving that whole function to a variable and naming it squared. Now it's possible to use this variable anywhere else in your snippet.

You can also call functions directly in the {=} (Formula Command) command by using parenthesis () and passing your arguments directly.

For example:

A common use case for functions is manipulating lists. The filter(), map() and reduce() built-in functions are three functions for operating across a list that use functions.

Supported Operators

The Blaze Formula Language supports many operators for working with the various supported values. You can manipulate numbers, compare values, work with strings, and handle boolean (yes/no) values.

Text Blaze will convert between these when suitable in formulas. If you try to use types in a way that is not supported (e.g. 12 + yes or "abc" * 2) an error will be shown.

Math Operators

Text Blaze provides you with a few general Math operators for working with numbers.

OperatorDescriptionExample
+Add two numbers together5 + 6 ⇒ 11
-Subtract two numbers7 - 2 ⇒ 5
*Multiply two numbers5 * 2 ⇒ 10
/Divide two numbers9 / 2 ⇒ 4.5
^Take a number to a power2 ^ 3 ⇒ 8

Comparison Operators

Comparison operators are very useful for comparing two values. The final result will always resolve into a Boolean (yes/no) value. You'll use these a lot when creating conditions for the {if} command.

OperatorDescriptionExample
=Whether two values are equal (can convert types)2 = 2 ⇒ yes
<>Whether two values are not equal (can convert types)2 <> 2 ⇒ no
>=Greater than or equals to5 >= 2 ⇒ yes
>Greater than5 > 2 ⇒ yes
<=Less than or equals to5 <= 2 ⇒ no
<Less than5 < 2 ⇒ no
For more information on using the if command, see the {if} command's documentation page.

String Operators

Text Blaze provides you with one operator, the & operator, to help you concatenate strings together.

Text Blaze provides you with plenty of string built-in functions to work with strings further.

OperatorDescriptionExample
&String concatenation"abc" & "xyz" & 1 ⇒ "abcxyz1"

Logical Operators

These operators are very useful for working with Boolean (yes/no) values.

OperatorDescriptionExample
notThe opposite of a booleannot no ⇒ yes
andWhether two booleans are both trueyes and no ⇒ no
orWhether either of two booleans is trueyes or no ⇒ yes
ternaryConditional value. Of the form: value1 if condition else value2"big" if 100 > 10 else "small" ⇒ "big"

Take note of the second example in the above snippet.

It's possible to combine comparison operators always resolve into a Boolean (yes/no) value, so it's possible to combine them with Logical operators.

Also, note how the third example, the ternary operator, outputs the second value because the condition isn't met.

Built-in Functions

Besides operators that allow you to work with the various Text Blaze supported values, you also get access to built-in functions.

A built-in function is a contained piece of functionality designed to perform a particular task.

Text Blaze supports a variety of these built-in functions for you to use in your snippets.

All functions resolve into a supported value, so that means it's possible to use functions as the argument to another function.

Math Functions

FunctionDescriptionExample
round(x)Rounds a number to the nearest integerround(1.7) ⇒ 2
floor(x)Rounds a number down to the nearest integerfloor(1.7) ⇒ 1
ceil(x)Rounds a number up to the nearest integerceil(1.2) ⇒ 2
sqrt(x)Gets the square root of a numbersqrt(16) ⇒ 4
abs(x)Gets the absolute value of a numberabs(-3) ⇒ 3
log(x)Gets the base-10 log of a numberlog(100) ⇒ 2
ln(x)Gets the natural log of a numberln(100) ⇒ 4.605
remainder(x, y)Gets the remainder from a divisionremainder(12, 5) ⇒ 2
max(x, y, ...)Gets the maximum of two or more valuesmax(3, 7) ⇒ 7
min(x, y, ...)Gets the minimum of two or more valuesmin(3, 7) ⇒ 3
isodd(x)Whether a number is oddisodd(7) ⇒ yes
iseven(x)Whether a number is eveniseven(7) ⇒ no
random()Gets a random number between 0 and 1random() ⇒ 0.370826324
base(x, base, padding)Express numbers in different numeric bases (e.g. hexadecimal)base(123, 16) ⇒ "7b"

Try it out

  • Try combining a math operator after the random() to increase the range of the random number. For example random() * 10

Trigonometric Functions

Similar to the Math functions these built-in functions are designed to help you work with trigonometry.

All of these functions take a single number as an argument and return a single number.

FunctionDescriptionExample
sin(x)Returns the sine of a number of degreessin(90) ⇒ 1
cos(x)Returns the cosine of a number of degreescos(90) ⇒ 0
tan(x)Returns the tangent of a number of degreestan(45) ⇒ 1
asin(x)Returns the arcsine in degrees of a numberasin(1) ⇒ 90
acos(x)Returns the arccosine in degrees of a numberacos(0) ⇒ 90
atan(x)Returns the arctangent in degrees of a numberatan(1) ⇒ 45

Some of Text Blaze's trigonometric functions are approximate. Due to the numerical approaches to determine their values, there may be extremely small errors in their output (in the 10th decimal place or beyond).

For example, instead of equalling exactly 0, cos(90) could instead return 0.00000000000000006123.

Because of this, you may need to round results from these functions when formatting them for output with the round() function.

For example, you can do round(cos(90)) to get 0.

Statistical Functions

Similar to the Math functions and Trigonometric functions these built-in functions are designed to help you work with statistics.

FunctionDescriptionExample
average(list)The average (mean) of the elements in a listaverage([1, 4, 10]) ⇒ 5
median(list)The median of the elements in a listmedian([1, 4, 10]) ⇒ 4
stddevpop(list)The population standard deviation of the elements in a liststddevpop([0, 1, 4, 9]) ⇒ 3.5
variancepop(list)The population variance of the elements in a listvariancepop([0, 1, 4, 9]) ⇒ 12.25
stddevsamp(list)The sample standard deviation of the elements in a liststddevsamp([1, 2, 3]) ⇒ 1
variancesamp(list)The sample variance of the elements in a listvariancesamp([1, 2, 3]) ⇒ 1
normdist(number, mean, standard_deviation, cumulative)Normal distribution function for a number given mean and standard deviationnormdist(0, 0, 1, yes) ⇒ 0.5
norminv(number, mean, standard_deviation)Inverse normal distribution function for a number given mean and standard deviationnorminv(0.5, 0, 1) ⇒ 0
ztest(list, value, standard_deviation (optional))The one-tailed p-value of a z-test with standard distribution, i.e., the probability of the sample mean being greater than the observed value, given a population mean. If the standard deviation is not provided, the sample standard deviation will be usedztest([1, 2, 3], 2) ⇒ 0.5
tdist(number, degrees_freedom, cumulative)Left-tailed Student's t-distribution function for a number given degrees of freedomtdist(0, 2, yes) ⇒ 0.5
tinv(number, degrees_freedom)Left-tailed inverse Student's t-distribution function for a number given degrees of freedomtinv(0.5, 1) ⇒ 0
ttest(list1, list2, tails, type)The probability associated with a Student's t-test. This test determines whether two samples are likely to have come from two populations that have the same mean. It requires the type to be either "PAIRED", "HOMOSCEDASTIC" (equal variance), or "HETEROSCEDASTIC" (unequal variance)ttest([1, 2, 3], [1, 2, 3], 1, "HOMOSCEDASTIC") ⇒ 0.5

Some of Text Blaze's statistical functions are approximate. Due to the numerical approaches to determine their values, there may be extremely small errors in their output.

For example, tdist(0, 1, yes) returns 0.500000018007351, but it should be 0.5. You can use the round function in this case: round(tdist(0, 1, yes), 2) will give 0.50.

Error Functions

There are often times when errors will appear in your snippets.

For example, if a form isn't validated or a function returns no value. To help you deal with these scenarios, Text Blaze provides you with two different error built-in functions.

FunctionDescriptionExample
error(msg)Raises a Text Blaze errorerror("Invalid widget size")
catch(x, msg)Evaluates and returns x. If there is an error in x, returns msg. msg may also be an anonymous function taking the error as its first argumentcatch(log(-1), "Negative") ⇒ "Negative"
  • Along with the error() function you also have access to the {error} command that can be used to block snippet insertion and to validate inputs.
  • Learn more about the {site} command and what capabilities it offers you.

Text String Functions

Text Blaze provides you with built-in string functions to help you work with Text Strings.

FunctionDescriptionExample
concat(x, y, ...)Concatenates two or more values as a stringconcat("abc", 123) ⇒ "abc123"
lower(x)Lowercase a stringlower("Hi") ⇒ "hi"
upper(x)Uppercase a stringupper("Hi") ⇒ "HI"
left(x, count)Leftmost charactersleft("Hi all", 2) ⇒ "Hi"
right(x, count)Rightmost charactersright("Hi all", 2) ⇒ "ll"
proper(x)Capitalizes each wordproper("HI all") ⇒ "Hi All"
trim(x)Removes leading and trailing whitespacetrim(" abc ") ⇒ "abc"
reverse(x)Reverses a stringreverse("abc") ⇒ "cba"
replace(x, find, replacement)Replaces all occurrences of find with replacementreplace("good job", "good", "great") ⇒ "great job"
len(x)The length of a string in characterslen("abc") ⇒ 3
substring(x, start, length)Extracts the portion of the string of length from the start character. If start is negative, it is relative to the end of the string. If length is omitted, the rest of the string is returned.substring("abcdef", 2, 3) ⇒ "bcd"
comparestrings(a, b)Returns a negative number if a is lexicographically before b, a positive number if b is before a and 0 if they are equivalent.comparestrings("at", "dog") ⇒ -1
contains(string, value)Whether one string contains anothercontains("Good morning", "morning") ⇒ yes
startswith(string, value)Whether one string starts with anotherstartswith("Good morning", "morning") ⇒ no
endswith(string, value)Whether one string ends with anotherendswith("Good morning", "morning") ⇒ yes
search(string, value)The position of one string in anothersearch("Good morning", "morning") ⇒ 6
  • Note how strings use len() to check length, and lists use count() to check the list's length.
  • Learn more about the {error} command and how it can help you block insertion in your snippets.

Regular Expression Functions

Regular Expressions are a very powerful tool to help you create search patterns.

Make sure you review the Regular Expressions section of this page to learn more about RegEx is and how they can help you in your snippets.
FunctionDescriptionExample
testregex(x, regex, flags)Tests whether a regular expression matches a stringtestregex("dog", "d..") ⇒ yes
extractregex(x, regex, flags)Extracts the portion of a string matching a regular expression. If a capture group is set, extracts the capture groupextractregex("dog", "d(..)") ⇒ "og"
extractregexall(x, regex, flags)Like extractregex, but gets all the matches rather than just the firstextractregexall("dog den", "d(..)") ⇒ ["og", "en"]
splitregex(x, regex, flags)Splits a string by a regular expressionsplitregex("ab5cd3ef", "\d") ⇒ ["ab", "cd", "ef"]
replaceregex(x, regex, replacement, flags)Replaces matches of a regular expression in a stringreplaceregex("ID: 1234", "\d", "X", "g") ⇒ "ID: XXXX"

Supported flags

In all the above regex functions, flags is an optional argument. It can be set to a string containing any of these characters:

  1. When the ignore case flag ("i") is set, the search will be case-insensitive.
  2. When the multi-line flag ("s") is set, the "." special character will match multiple lines.
  3. The global flag ("g") is only supported in replaceregex. When it is set, the search will replace all matches instead of only the first match.

Here's an example using the multi-line and ignore-case flags ("is"):

  • A common use case for the {clipboard} command is extracting specific data with RegEx functions.
  • Also notice how it's possible to use a command as an argument for a function.
  • Learn regular expressions by going through an extract email adress example.

Date Time Functions

These functions do calculations based on date and times. Other than datetimeparse, these functions require the date to be in the format YYYY-MM-DD or YYYY-MM-DD HH:MM:SS. datetimeparse can be used to convert a date to that format.

FunctionDescriptionExample
datetimeparse(date, format)Parse a datedatetimeparse("Jan 23, 2020", "MMM D, YYYY") ⇒ 2020-01-23
datetimeformat(date, format)Format a datedatetimeformat("2020-01-23", "MMM D, YYYY") ⇒ Jan 23, 2020
datetimeadd(date, amount, units)Adds time to a datedatetimeadd("2020-01-23", 9, "D") ⇒ 2020-02-01
datetimediff(date, date, units)Finds the difference between two datesdatetimediff("2020-01-23", "2020-02-01", "D") ⇒ 9
Note that you can also use the {time} command in your formulas.

List Functions

These functions work on both ordered lists and keyed lists.

The output of these functions depends on which function you choose. Some functions return lists, others a Boolean (yes/no) value, or a number.

FunctionDescriptionExample
count(list)The number of elements in a listcount([1, 4, 9]) ⇒ 3
includes(list, value)yes if a list contains a specific valueincludes([1, 4, 9], 4) ⇒ yes
location(list, value)Returns the index or key of the first location of the valuelocation([1, 4, 9], 4) ⇒ 2
merge(list, list2, ...)Merges two or more lists togethermerge([1], [2, 3], [4]) ⇒ [1, 2, 3, 4]
filter(list, fn(value, index/key))Returns a new list comprised of the elements where fn evaluates to yesfilter([1, 4, 9], v -> v > 3) ⇒ [4, 9]
map(list, fn(value, index/key))Returns a new list where each element is replaced with the value of fnmap([1, 4, 9], v -> v > 3) ⇒ [no, yes, yes]
reduce(list, accumulator, fn(accumulator, value, index/key))Aggregates the elements of the listreduce([1, 4, 9], 0, (a, v) -> a + v) ⇒ 14
any(x, y, ...)Whether any value in the list is yesany([yes, no, no]) ⇒ yes
every(x, y, ...)Whether every value in the list is yesevery([yes, no, no]) ⇒ no
  • We're using the {=} (Formula Command) command's assignment mode to assign a value to a variable.

Ordered List Functions

The following functions only work on ordered lists.

FunctionDescriptionExample
seq(start, end, step)Creates an ordered list from start to end by step. If step is omitted, it defaults to 1 or -1.seq(1, 3) ⇒ [1, 2, 3]
split(str, del)Creates an ordered list by splitting a string by a deliminatorsplit("a/b/c", "/") ⇒ ["a", "b", "c"]
join(list, del)Creates a string by joining the elements of a listjoin([1, 3, 9], "-") ⇒ 1-3-9
sort(list, fn(a, b))Sorts the elements of the ordered list. fn(a, b) will be called for each pair of elements; if is negative, a will be placed before b; if positive, b will be placed before a; if 0, the elements are equivalentsort([3, 9, 1], (a, b) -> a - b) ⇒ [1, 3, 9]
slice(list, start, last)Extract part of the list from start to last. If last is omitted, returns from start to the end of the listslice([1, 4, 9, 16], 2, 3) ⇒ [4, 9]
sum(list)Sum the elements of a listsum([1, 4, 10]) ⇒ 15
find(list, fn)Returns the first element of a list that matches a conditionfind([1, 4, 9], x -> x > 3) ⇒ 4
unique(list)Removes duplicatesunique(["A", "A", "B"]) ⇒ ["A", "B"]
  • It's possible to use Text Blaze's special delimiters as a replacement for the join() function's second parameter.

Keyed List Functions

The following only work on Text Blaze's keyed lists.

FunctionDescriptionExample
keys(list)The keys in a keyed list as an ordered listkeys(["a": 123, "b": 345]) ⇒ ["a", "b"]

Information Functions

The following functions all return a Boolean (yes/no) value. They're especially useful when used in combination with the {if} command.

FunctionDescriptionExample
isnumber(x)Whether a value is a numberisnumber("1.2") ⇒ yes
isboolean(x)Whether a value is a booleanisboolean("no") ⇒ yes
islist(x)Whether a value is a listislist([1,2,3]) ⇒ yes
iserror(x)Whether a value is an erroriserror(1 + "a") ⇒ yes

Data Encoding Functions

These are very helpful functions to help with encoding. The urlencode() and urldecode() functions in particular are very useful when working with the {link} and {image} commands.

FunctionDescriptionExample
urlencode(x)Encodes special characters to allow including a string in a urlurlencode("a&b") ⇒ "a%26b"
urldecode(x)Decodes a urlencoded stringurlencode("a%26b") ⇒ "a&b"
base64encode(x)Base 64 encode a stringbase64encode("hello") ⇒ "aGVsbG8="
base64decode(x)Base 64 decode a stringbase64decode("aGVsbG8=") ⇒ "hello"

JSON Functions

There's a useful function built into Text Blaze that will help you work with JSON. This is very useful if you already have JSON and need this data available in your snippet.

FunctionDescriptionExample
fromjson(str)Converts a JSON string into a listfromjson("{\"a\": [1,2,3]}") ⇒ ["a": [1, 2, 3]]

Escaping Special Characters

Certain characters have special meaning in Text Blaze commands and strings. For instance, the ; character is used to separate settings in commands. In formula strings, the " character is used to signal the start and end of the string.

To use these special characters in their normal form you can "escape" them by placing a single backslash (\) before them.

For example:

{="this is a \" character"}

will print:

this is a " character

The rules for escaping special characters are slightly different within commands and strings. The following table summarizes these rules:

In CommandsIn Strings
Common escapes: \n, \r, \t, \\Replaced with newline, carriage return, tab, and \ respectivelyReplaced with newline, carriage return, tab, and \ respectively
Special characters that need to be escaped{, }, =, ;, and spaces at the start or end of a setting (and within the values of list settings: ,)"
Any other occurrences of \XBackslashes are stripped. E.g. \a\b\c becomes abcBackslashes remain. E.g. \a\b\c stays as \a\b\c

Additional common escapes may be added to Text Blaze in the future, so you should be explicit with your backslashes and not accidentally rely on the behaviors in the third row of this table.

Special Delimiters

Text Blaze has two special delimiters you can use that join the items together using natural language concatenation: "BLAZE_AND" and "BLAZE_OR". These can be particularly useful in the formatter function for the {formmenu} command.

For example:

List Comprehensions

Text Blaze has powerful built-in functions for transforming lists: including filter(), map(), and reduce().

Sometimes though, it can be easier to use a powerful Text Blaze feature called list comprehensions if you need to transform a list. List comprehensions carry out an operation across each element of a list.

Imagine you wanted to square each element of an ordered list. The following example shows how to do that with both the map() function and a list comprehension:

Both work and are almost exactly the same length, but many people find the list comprehension version easier to read.

You can also include an optional if block in your list comprehensions, items will only be included when it evaluates to yes. Imagine we only wanted to include items who were larger than 20:

Note: Using the if keyword in the context of list comprehensions is separate from the ternary statement.

List Comprehensions with Keyed Lists

List comprehensions can also iterate across keyed lists and can create keyed lists. The following shows the examples of the different possible combinations:

Multi-line formulas

Text Blaze supports multi-line formulas with code blocks.

Variable scopes

In general, all variables in Text Blaze are part of one global scope. There are a few exceptions to this. In these exceptions local scopes are created that have access to the global scope variables but may contain additional variables that are not in the global scope:

  1. The {repeat} command, creates a separate local scope for each iteration of the repeat]. This allows you to create form fields within repeat's that are independent of one another. You can use the {repeat} command's locals setting to access these local variables in your global scope.
  2. User defined functions will create a local scope with any parameters passed to the function.
  3. Code blocks can create variables local to the code block using the var statement.

Regular Expressions

A regular expression pattern is composed of simple characters, such as "abc", or a combination of simple and special characters, such as "ab*c" or "Chapter (\d+)\.\d*". The last example includes parentheses which can be used to extract specific parts of the regex using the extractregex() function.

This section is adapted from this MDN Page by Mozilla Contributors and licensed under CC-BY-SA license.

Text Blaze provides you with a variety of regular expression built-in functions for you to leverage regular expressions with.

Regular expressions are a powerful feature of Text Blaze. They're commonly used with the {clipboard} command for grabbing specific pieces of data from your clipboard.

Using simple patterns

Simple patterns are constructed of characters for which you want to find a direct match. For example, the pattern "abc" matches character combinations in strings only when exactly the characters 'abc' occur together and in that order. Such a match would succeed in the strings "Hi, do you know your abc's?" and "The latest airplane designs evolved from slabcraft." In both cases, the match is with the substring 'abc'. There is no match in the string 'Grab crab' because while it contains the substring 'ab c', it does not contain the exact substring 'abc'.

Using special characters

When the search for a match requires something more than a direct match, such as finding one or more b's, or finding white space, the pattern includes special characters. For example, the pattern "ab*c" matches any character combination in which a single 'a' is followed by zero or more 'b's (* means 0 or more occurrences of the preceding item) and then immediately followed by 'c'. In the string "cbbabbbbcdebc," the pattern matches the substring 'abbbbc'.

The table at the end of this section provides a complete list and description of the special characters that can be used in regular expressions.

Special characters in regular expressions

The following table is a list of special characters that can be used in regular expressions:

CharacterMeaning
\Matches according to the following rules:

A backslash that precedes a non-special character indicates that the next character is special and is not to be interpreted literally. For example, a 'b' without a preceding '' generally matches lowercase 'b's wherever they occur. But a '\b' by itself doesn't match any character; it forms the special word boundary character.

A backslash that precedes a special character indicates that the next character is not special and should be interpreted literally. For example, the pattern "a*" relies on the special character '\*' to match 0 or more a's. By contrast, the pattern "a\*" removes the specialness of the '*' to enable matches with strings like 'a*'.

To match a \ you need to escape it as \\. If you are entering your regex as a string directly in your snippet, you will need to double escape it (\\\\) as a \\ is replaced by a single \ in Text Blaze quoted strings.
^Matches the beginning of input.

For example, "^A" does not match the 'A' in "an A", but does match the 'A' in "An E".

The '^' has a different meaning when it appears as the first character in a character set pattern. See complemented character sets for details and an example.
$Matches end of input.

For example, "t$" does not match the 't' in "eater", but does match it in "eat".
*Matches the preceding expression 0 or more times. Equivalent to {0,}.

For example, "bo*" matches 'boooo' in "A ghost booooed" and 'b' in "A bird warbled" but nothing in "A goat grunted".
+Matches the preceding expression 1 or more times. Equivalent to {1,}.

For example, "a+" matches the 'a' in "candy" and all the a's in "caaaaaaandy", but nothing in "cndy".
?Matches the preceding expression 0 or 1 time. Equivalent to {0,1}.

For example, "e?le?" matches the 'el' in "angel" and the 'le' in "angle" and also the 'l' in "oslo".

If used immediately after any of the quantifiers *, +, ?, or {}, makes the quantifier non-greedy (matching the fewest possible characters), as opposed to the default, which is greedy (matching as many characters as possible). For example, applying "\d+" to "123abc" matches "123". But applying "\d+?" to that same string matches only the "1".
.(The decimal point) matches any single character except the newline character.

For example, ".n" matches 'an' and 'on' in "nay, an apple is on the tree", but not 'nay'.
x|yMatches 'x', or 'y' (if there is no match for 'x').

For example, "green|red" matches 'green' in "green apple" and 'red' in "red apple." The order of 'x' and 'y' matters. For example "a*|b" matches the empty string in "b", but "b|a*" matches "b" in the same string.
{n}Matches exactly n occurrences of the preceding expression. N must be a positive integer.

For example, "a{2}" doesn't match the 'a' in "candy," but it does match all of the a's in "caandy," and the first two a's in "caaandy."
{n,}Matches at least n occurrences of the preceding expression. N must be a positive integer.

For example, "a{2,}" will match "aa", "aaaa" and "aaaaa" but not "a"
{n,m}Where n and m are positive integers and n <= m. Matches at least n and at most m occurrences of the preceding expression. When m is omitted, it's treated as ∞.

For example, "a{1,3}" matches nothing in "cndy", the 'a' in "candy," the first two a's in "caandy," and the first three a's in "caaaaaaandy". Notice that when matching "caaaaaaandy", the match is "aaa", even though the original string had more a's in it.
[xyz]Character set. This pattern type matches any one of the characters in the brackets, including escape sequences. Special characters like the dot(.) and asterisk (*) are not special inside a character set, so they don't need to be escaped. You can specify a range of characters by using a hyphen, as the following examples illustrate.

The pattern [a-d], which performs the same match as [abcd], matches the 'b' in "brisket" and the 'c' in "city". The patterns "[a-z.]+" and "[\w.]+" match the entire string "test.i.ng".
[^xyz]A negated or complemented character set. That is, it matches anything that is not enclosed in the brackets. You can specify a range of characters by using a hyphen. Everything that works in the normal character set also works here.

For example, [^abc] is the same as [^a-c]. They initially match 'r' in "brisket" and 'h' in "chop."
[\b]Matches a backspace (U+0008). You need to use square brackets if you want to match a literal backspace character. (Not to be confused with \b.)
\bMatches a word boundary. A word boundary matches the position where a word character is not followed or preceded by another word-character. Note that a matched word boundary is not included in the match. In other words, the length of a matched word boundary is zero. (Not to be confused with [\b].)

Examples:
"\bm" matches the 'm' in "moon" ;
"oo\b" does not match the 'oo' in "moon", because 'oo' is followed by 'n' which is a word character;
"oon\b" matches the 'oon' in "moon", because 'oon' is the end of the string, thus not followed by a word character;
"\w\b\w" will never match anything, because a word character can never be followed by both a non-word and a word character.

Note: The regular expression engine defines a specific set of characters to be "word" characters. Any character not in that set is considered a word break. This set of characters is fairly limited: it consists solely of the Roman alphabet in both upper- and lower-case, decimal digits, and the underscore character. Accented characters, such as "é" or "ü" are, unfortunately, treated as word breaks.
\BMatches a non-word boundary. This matches a position where the previous and next character are of the same type: Either both must be words, or both must be non-words. The beginning and end of a string are considered non-words.

For example, "\B.." matches 'oo' in "noonday", and "y\B." matches 'ye' in "possibly yesterday."
\dMatches a digit character. Equivalent to [0-9].

For example, "\d" or "[0-9]" matches '2' in "B2 is the suite number."
\DMatches a non-digit character. Equivalent to [^0-9].

For example, "\D" or "[^0-9]" matches 'B' in "B2 is the suite number."
\sMatches a single white space character, including space, tab, form feed, line feed. For example, "\s\w*" matches ' bar' in "foo bar."
\SMatches a single character other than white space. For example, "\S*" matches 'foo' in "foo bar."
\wMatches any alphanumeric character including the underscore. For example, "\w" matches 'a' in "apple," '5' in "$5.28," and '3' in "3D."
\WMatches any non-word character. For example, "\W" matches '%' in "50%."

More Regular Expression Examples

Let's build out a snippet to extract an email address.

Try it out

  • Change the email address in the text field.
  • Try removing the space after the .co.uk.
  • Try changing .co.uk to .com
  • You can see both of these examples at work in the video, as well as how they're used in conjunction with the extractregex(), testregex(), and replaceregex() regular expression functions.

Here's what's happening:

\w+@ is matching all word characters prior to the @ symbol. [.\w]+\b is matching as many periods and word characters as it can, up until a word boundary (meaning a punctuation mark followed by a space).

Here are some further clarifications of the special characters being used:

The period character (.) has a special meaning in regex (see the list provided above). If you want RegEx to interpret the period character literally, you need to precede it with a backslash.

The square brackets mean "any combination of the included".

The \b represents the word boundary.

Of course, this is just the tip of the iceberg with RegEx.


We're always improving the Text Blaze documentation to make things more clear for you.

Next Steps

  • If you still have questions you can always post on our community. We're here to help!
  • Go through our examples to see various commands and the formula language in use.
  • Watch our YouTube videos for examples on using the Blaze Formula language and various commands.

About

Plans and Pricing
Sharing Snippets
Text Blaze for Business
Forms
Autopilot
Dynamic Commands
Command Packs
Text Blaze for Windows
Text Blaze for macOS

Support

Get Started with Text Blaze
Contact Us
Documentation
Community Forum
Blog
Gallery
Engineering Blog

Solution for

Business
Customer Support
Recruiters
Education
Healthcare
Sales
Property Managers
AI

Other

Privacy Policy
Terms of Service
Open Source Licenses
Affiliate
© 2025 Blaze Today Inc