Ask AI
Skip to main content

Transform string to prefixes

Function: Transform string to prefixes

This action takes a piece of text (a string) and breaks it down into all its possible starting segments, also known as prefixes. It then provides you with a list containing each of these prefixes. This is useful for tasks like creating search suggestions, auto-completion features, or analyzing text patterns.

Input

  • String: A piece of text. This is the text you want to break down into its prefixes.
    • Type: A piece of text
    • Required: Yes

Output

  • Result: A list of values. This is the variable that will hold the generated list of prefixes. For example, if the input is "apple", the output list will be ["a", "ap", "app", "appl", "apple"].
    • Type: A list of values

Execution Flow

Real-Life Examples

Here are some practical ways you can use the "Transform string to prefixes" action:

  1. Generating Search Suggestions:

    • Scenario: You want to create a dynamic search bar that suggests terms as a user types.
    • Inputs:
      • String: product
    • Result: The Result variable will contain the list: ["p", "pr", "pro", "prod", "produ", "produc", "product"]. You can then use this list to query your product database for matching suggestions.
  2. Auto-completing a Reference Code:

    • Scenario: A user is entering a long reference code (e.g., for an invoice or order) and you want to provide auto-completion options.
    • Inputs:
      • String: INV-2023-001
    • Result: The Result variable will contain the list: ["I", "IN", "INV", "INV-", "INV-2", "INV-20", "INV-202", "INV-2023", "INV-2023-", "INV-2023-0", "INV-2023-00", "INV-2023-001"]. This list can be used to match against existing codes.
  3. Creating Partial Tags for Filtering:

    • Scenario: You have a system where items are tagged, and you want to allow users to filter by typing partial tag names.
    • Inputs:
      • String: marketing
    • Result: The Result variable will contain the list: ["m", "ma", "mar", "mark", "marke", "market", "marketi", "marketin", "marketing"]. This list can be used to find all items tagged with any of these prefixes.