Comment on page
Text Filters
Text filters enable you to transform and manipulate text.
- ​istarts_with - Returns whether or not the case-insensitive expression is present at the beginning.
- ​regex_get_all_matches - Return all matches performed by a regular expression on the supplied subject text.
- ​regex_get_first_match - Return the first set of matches performed by a regular expression on the supplied subject text.
- ​url_addarg - Parses a URL and returns an updated version with an encoded version of the supplied argument.
Adds a backslash to the following characters: single quote, double quote, backslash, and null character.

Converts the first letter of each word to a capital letter.

Example: we have a text value of hello world and apply the capitalize filter and it becomes Hello World.
Concatenates 2 text strings together by an optional separator. The value can be any text and the separator can be anything: + , -, _, a space, etc...

Example: we have a text value of hello world and apply the concat filter and it becomes hello world+Xano.
​
Returns whether or not the expression is found and is case-sensitive. The search term can be any string of text.
This returns a "true" or "false" response.

Example: we have a text value of hello world and apply the contains filter this returns a value of "true
Converts an encoded text element from one type of encoding to another

Detects the encoding of a text element. Use the Encodings parameter to specify the encodings to check against, or leave blank to auto-detect

Returns whether or not the expression is present at the end. The search term can be any string of text.
This returns a "true" or "false" response.
Example: we have a text value of hello world and apply the ends_with filter this returns a value of "false".
Returns whether or not the case-insensitive expression is found. The search term can be any string of text.
This returns a "true" or "false" response.
Example: we have a text value of hello world and apply the icontains filter this returns a value of "false".
Returns whether or not the case-insensitive expression is present at the end. The search term can be any string of text.
This returns a "true" or "false" response.
Example: we have a text value of hello world and apply the iends_with filter this returns a value of "true".
Returns the index of the case-insensitive expression or false if it can't be found. The search term can be any string of text.
This returns an integer value of where the character(s) exist in the string. The first character in a text string has an index of 0.
Example: we have a text value of hello world and apply the iindex filter this returns a value of "6".
Returns the index of the case-sensitive expression or false if it can't be found. The search term can be any string of text.
This returns an integer value of where the character(s) exist in the string. The first character in a text string has an index of 0.
Example: we have a text value of hello world and apply the index filter this returns a value of "1".
Returns whether or not the case-insensitive expression is present at the beginning. The search term can be any string of text.
This returns a "true" or "false" response.
Example: we have a text value of hello world and apply the istarts_with filter this returns a value of "true".
Trim whitespace or other characters from the left side and return the result. The mask text can be any string of text.
Example: we have a text value of hello world and apply the ltrim filter this returns a value of "llo world".
Trim whitespace or other characters from the right return the result. The mask text can be any string of text.
Example: we have a text value of hello world and apply the ltrim filter this returns a value of "hello wo".
Extracts query strings from a URL and places them into separate key/value pairs.
The example below separates a URL using the url_parse filter, and then uses querystring_parse to parse the query parameters into separate keys and values.

The test URL

The function and querystring_parse filter

The result
Joins an array of text into text via the separator and returns the result. Theseperator text can be any string of text.
The array in this example is:
[ hello, world, how, are, you]
Example: we have an array of text and we apply the join filter with the seperator "?" this returns: hello?world?how?are?you
Regex or regular expression is a more advance topic that can be useful for finding patterns in text. It is a string of text that allows you to create patterns that help match, locate, and manage text.
Regex typically includes something called delimiters to set the boundaries of the expression. Often times, / will be used as delimiters but almost any character can be used.
Regex filters inside the Query All Records function do not use delimiters. Regex filters in any other variable, function, etc. in Xano require delimiters.
Regex uses special characters, for example:
. is any character
\d is any number
\s is any whitespace
\w is any word character
* means 0 or more
+ means 1 or more
​
Regex uses additional special characters, these are just to name a few as an example.
Some special characters need the \ escape character, which is why regex_quote can be useful to determine this. For example, . and $ do but @ does not.
You can then use ( ) to group matches. For example:
/(\w+)@\w+\.\w+/ this would get name of and full email address
​
​
/ is the starting delimiter
(\w+) is a matching group, this group must be at least 1 or more word character
@ is the symbold @
\w+ is at least 1 or more word character
\. is the symbol .
\w+ is at least 1 or more word character
/ is the ending delimiter
​
Return all matches performed by a regular expression on the supplied subject text.

In this example, we are searching for all matches of /you/ which will return two matches [you, you].
Return the first set of matches performed by a regular expression on the supplied subject text.

In this example, we are searching for the phrase h with one more additional word characters. The result is how and not Hi because this is case-sensitive.
Tests if a regular expression matches the supplied subject text. Returns a true or false boolean.

In this example, we are seeing if the subject matches the provided regex. The result will be true because how matches /h\w+/ which is a string starting with h and having one or more word characters after.
Update the supplied text value to be properly escaped for regular expressions.


The result using / as a delimiter.
Perform a regular expression search and replace on the supplied subject text.

In this example, we are using /(\w+)@\w+\.\w+/ to find an email address and using the replacement to replace it with [email protected]. The result is please email [email protected]
Replace a text phrase with another. Search can be any word in the value and the replacement can be anything.

Example: we have a text value of hello world and apply the replace filter and it becomes hello Xano.
Splits text into an array of text and returns the result. The separator can be anything the words are separated by, in this example, it is the + symbol.

Example: we have a text value of hello+world and apply the split filter and it becomes ["hello", "world"].
We can combine multiple filters to format a text string into an array.
For example, we have the string "a , b,c, d"
Notice the inconsistent spaces. If all we do is use split then the spaces will persist in the array. We can combine trim and filter_empty filters to remove unnecessary spaces or blank values.

Formats text with variable substitution. This is helpful when wanting to substitute a URL string with a variable that either the use provides or that is gotten from the result of a previous function.
- %d is used to replace a number and will enforce a number.
- %s is used to replace text.
The first example shows how to use variable substitution with a number using %d.
Example: we have a text value of hello world %d and apply the sprintf filter, it becomes hello world 54321.
The second example will replace %s with text:
Example: we have a text value of hello world %s and apply the sprintf filter, it becomes hello world anything.
We can use multiple arguments on the sprintf filter to replace any number of values. In the example below we have 2 %d and 2 %s.
The first %d is equivalent to the first argument of 123.
The second %d is equivalent to the second argument of 789.
The first %s is equivalent to the first argument of hi.
The first %s is equivalent to the second argument of end.
This example becomes: 123 hello 789 world hi this is the end
If you have a % character in your text that you would NOT like to replace with the
sprintf
filter you are able to escape the filter by adding an additional % character next to the existing % character. "Example: "%%"Returns whether or not the expression is present at the beginning. The search term can be any string of text and is case-sensitive.
This returns a "true" or "false" response.
Example: we have a text value of hello world and apply the starts_with filter this returns a value of "false".
Returns the number of characters.

Example: we have a text value of hello world and apply the strlen filter and it becomes the int 11.
Removes accents from characters

Extracts a section of text. The start pos is based on the # of characters from the beginning with the first char pos= 0. The length can be an int.

Example: we have a text value of hello world and apply the substr filter and it becomes wo.
Converts all characters to lower case and returns the result.

Example: we have a text value of HeLLo WoRlD and apply the to_lower filter and it becomes hello world.
Converts all characters to upper case and returns the result.

Example: we have a text value of HeLLo WoRlD and apply the to_upper filter and it becomes HELLO WORLD.
Trim whitespace or other characters from both sides and return the result. The mask text can be any string of text.
Example: we have a text value of ?!hello world?! and apply the trim filter this returns a value of "hello world".
Parses a URL and returns an updated version with an encoded version of the supplied parameter.
This filter is used to add a key(blog_id, authorname) and a value (123 , john). Those parameters would be added as ?blog_id=123 and ?authorname=john.
This URL becomes https://www.xano.com/?user_id=1 after the filter is applied
Parses a URL and returns an updated version with the supplied parameter removed.
This filter is used to delete a key(blog_id, authorname). Those parameters would be deleted at the end of a url as ?blog_id or ?authorname.
This URL becomes https://www.xano.com/ after the filter is applied
Returns the value of a query parameter in a URL.

Our sample URL

In this example, we are getting the value of the "another" query parameter.
Returns the existence of an arguments in the URL.

The result of this filter will be true because the argument test
Parses raw HTML and removes HTML tags, returning the remaining text.
For example, if you input HTML that contains a collection of <p> tags and want to remove these and only return the text. Good to use in succession with the split filter to parse several elements and separate them into an array.

In this example, we are stripping the tags from an HTML paragraph and returning the result.
Parses a URL into its individual components.
.png?alt=media&token=7bb00ed0-fbdb-4135-9c64-7391ccf1a032)
The result of this filter will parse the URL into its individual components.
.png?alt=media&token=b8812710-3cd4-4a75-8b6e-c82b0ffa1c30)
In this example, the filter parses the URL into its individual components.
Last modified 3mo ago