Skip to content

Text

The Text Operator enables working with text and templates. It provides functionality for text manipulation, formatting, and template rendering, allowing for dynamic content generation and text transformation.

  • Generating dynamic content from templates
  • Formatting text for display or processing
  • Extracting specific parts of text
  • Converting text between different formats
  • Creating URL-friendly slugs from text
  • Normalizing text input
  • Manipulating text case (uppercase, lowercase, etc.)
  • Finding and replacing text patterns
  • Processing user input
  • Preparing text for database storage

Renders a template with provided values using Mustache templating.

  • template (string): The template string with Mustache placeholders
  • values (object): The values to use for template rendering

Returns the rendered template as a string.

{
"template": "Hello, {{name}}! Welcome to {{company}}.",
"values": {
"name": "John Doe",
"company": "SyncMyOrders"
}
}

Trims whitespace and normalizes text by removing extra spaces.

  • text (string): The text to trim and normalize
  • removeExtraSpaces (boolean, optional): Whether to replace multiple spaces with a single space

Returns the trimmed and normalized text.

{
"text": " This text has extra spaces. ",
"removeExtraSpaces": true
}

Converts text to a different case format.

  • text (string): The text to convert
  • conversion (string): The type of conversion to perform (UPPER, LOWER, CAPITALIZE, TITLE_CASE)

Returns the text in the specified case format.

{
"text": "this is a sample text",
"conversion": "TITLE_CASE"
}

Finds and replaces text patterns.

  • text (string): The text to process
  • find (string): The text to find
  • replace (string): The text to replace it with
  • replaceAll (boolean, optional): Whether to replace all occurrences or just the first one

Returns the text with replacements applied.

{
"text": "The quick brown fox jumps over the lazy dog",
"find": "fox",
"replace": "cat",
"replaceAll": true
}

Extracts the first line from text.

  • text (string): The text to process
  • trimResult (boolean, optional): Whether to trim the result

Returns the first line of the text.

{
"text": "First line\nSecond line\nThird line",
"trimResult": true
}

Extracts the first word from text.

  • text (string): The text to process
  • trimResult (boolean, optional): Whether to trim the result
  • delimiter (string, optional): The delimiter to use for splitting words (default is space)

Returns the first word of the text.

{
"text": "First word second word third word",
"trimResult": true,
"delimiter": " "
}

Splits text by one delimiter and joins it with another.

  • text (string): The text to process
  • splitBy (string): The delimiter to split by
  • joinWith (string): The delimiter to join with
  • trimParts (boolean, optional): Whether to trim each part before joining

Returns the text split and rejoined with the specified delimiters.

{
"text": "apple,orange,banana,grape",
"splitBy": ",",
"joinWith": " | ",
"trimParts": true
}

Removes specified characters from text.

  • text (string): The text to process
  • characters (string): The characters to remove
  • removeSpaces (boolean, optional): Whether to also remove spaces

Returns the text with specified characters removed.

{
"text": "Hello, World! 123",
"characters": ",.!123",
"removeSpaces": false
}

Extracts a substring from text.

  • text (string): The text to process
  • startIndex (integer): The starting index (0-based)
  • endIndex (integer, optional): The ending index (exclusive)
  • length (integer, optional): The length of the substring to extract (alternative to endIndex)

Returns the extracted substring.

{
"text": "The quick brown fox jumps over the lazy dog",
"startIndex": 4,
"length": 5
}

Collapses multiple lines into one or expands a single line into multiple lines.

  • text (string): The text to process
  • mode (string): The mode to use (COLLAPSE or EXPAND)
  • delimiter (string): The delimiter to use for collapsing or expanding

Returns the text with lines collapsed or expanded.

{
"text": "Line 1\nLine 2\nLine 3",
"mode": "COLLAPSE",
"delimiter": " | "
}

Converts text to a URL-friendly slug.

  • text (string): The text to convert to a slug
  • lowercase (boolean, optional): Whether to convert the slug to lowercase
  • separator (string, optional): The separator to use between words (default is ”-“)

Returns the slugified text.

{
"text": "This is a Sample Title! 123",
"lowercase": true,
"separator": "-"
}
  • The Text Operator uses Mustache for template rendering
  • Text operations are performed using Java’s string manipulation methods
  • Case conversion supports various formats (UPPER, LOWER, CAPITALIZE, TITLE_CASE)
  • The slugify operation removes special characters, replaces spaces with separators, and normalizes text
  • All operations handle null or empty input gracefully
  • The operator is useful for preparing text for display, storage, or further processing
  • Template rendering can use complex objects with nested properties