24
Views
2
Comments
Solved by AI
How to Check if Text Contains Any Word from a List
Application Type
Reactive

Hi everyone,

I’m working on a logic in OutSystems where I have:

1. List of Texts "WordList"

2. Text input "InputText"

I want to check if any word from the list exists in the input text. What’s the best way to implement this in OutSystems with the best performance? 

2019-01-31 08-54-57
André Costa
Champion
Solution

Hi Lukasz,


You can use the ListAny action, which is available under System Actions.

This action will determine if any of the elements in the list satisfies the given condition.

Ex: WordList.Text = InputText 


For more details, check the documentation here: Documentation

2023-12-26 10-35-28
OutSystems Neo
Staff
AI Generated

To efficiently check if any word from the WordList exists in the InputText, you can leverage the ListAny system action within OutSystems. This provides a concise and performant way to handle such conditions. Here's the approach:

  1. System Action: ListAny
    Use ListAny to iterate through your WordList and define a condition that checks if the InputText contains any word from the list.

  2. Implementation Details:

    • Set the Condition of the ListAny to:
      Index(InputText, CurrentWord) <> -1
      
      Where CurrentWord is the current element from the list during the iteration.
  3. Explanation:

    • The Index function will search for the current word (CurrentWord) in the InputText. If the word is found, it returns the starting index (0-based). If the word is not found, it returns -1.
    • The ListAny action stops as soon as one match is found, making it more performant than iterating through the whole list unnecessarily.
  4. Steps in OutSystems:

    • Drag the ListAny system action into your logic.
    • Assign the List to WordList.
    • Define the Condition for checking if InputText contains the current list element.

For cases with large WordList, you may also consider pre-processing or optimizing the list to avoid repetitive searches, depending on system constraints.

This method ensures effective performance while achieving your logic goals! For additional insights on similar use cases, refer to Find the given Text exists in the List of Text.

This answer was AI-generated. Please read it carefully and use the forums for clarifications
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.