strings#
RAI string values are represented by Expression
objects.
The relationalai.std.strings
module contains analogs of Python string methods for working with RAI strings.
The actual values of properties and other data in a RAI model are only determined during query evaluation in the RAI Native App.
As a result, the Python interpreter can’t access the types or values of data in the model, which means string data can’t be represented as Python str
objects.
To import the strings
module, add the following to the top of your Python file or notebook:
#import relationalai.std.strings as strings
Table Of Contents#
- Basic Operations
- Case Conversion
- String Filters
- Splitting and Joining Strings
- Fuzzy Matching
- Regular Expressions
Basic Operations#
These functions perform essential string manipulations, like concatenation, trimming, and substring extraction.
Function | Description |
---|---|
concat() | Concatenates two or more strings. |
length() | Gets the length of a string. |
strip() | Removes leading and trailing whitespace from a string. |
substring() | Extracts a substring from a string. |
replace() | Replaces all occurrences of a substring with another substring. |
Case Conversion#
Use these functions to convert strings between uppercase and lowercase formats.
Function | Description |
---|---|
lowercase() | Converts a string to lowercase. |
uppercase() | Converts a string to uppercase. |
String Filters#
Filter strings based on specific criteria, such as containing a substring or matching a pattern.
Function | Description |
---|---|
String() | Filters string values from a Producer . |
contains() | Filters strings that contain a substring. |
like() | Filters strings that match a SQL LIKE pattern. |
starts_with() | Filters strings that start with a substring. |
ends_with() | Filters strings that end with a substring. |
Splitting and Joining Strings#
These functions allow you to split strings into parts or join multiple strings into a single one.
Function | Description |
---|---|
split() | Splits strings into substrings. |
split_part() | Splits strings and returns the substring at a specified index. |
join() | Joins strings with a separator. |
Fuzzy Matching#
Use this function to measure string similarity for approximate matching tasks.
Function | Description |
---|---|
levenshtein() | Calculates the Levenshtein distance between two strings. |
Regular Expressions#
The functions in this section are deprecated and will be removed in a future release.
Use the functions in the relationalai.std.re
module instead.
Function | Description | Notes |
---|---|---|
regex_compile() | Compiles a regular expression pattern. | Deprecated |
regex_match() | Matches a string to a regular expression pattern. | Deprecated |