0

Replace array of items

Is it possible to utilize the replace() function with an array of options to check?

 

Something like:

replace('My Text', [ "Hello", "Goodbye", "Welcome" ], "Custom Message")

1 reply

null
    • Fred
    • 9 mths ago
    • Reported - view

    I'm not sure what you are asking exactly but here is one option.

    let myText := 'Text 2';
    let array := chosen(MC);
    for loop1 in array do
        myText := replace(myText, loop1, "BOB")
    end;
    myText
    

    I have a table with a field, 'Text 2', and simple multiple choice field, MC. The multiple choice field has three words that a user can select. 

    Line 1: I start by putting the data in 'Text 2' into a variable, myText. 

    Line 2: I put my selection(s) from the multiple choice into a variable, array.

    Line 3 has starts a for loop that will go through the array of possible words selected

    Line 4 takes what is in the variable myText and uses the replace() command to take the text in myText, looks for the word that is the loop and replaces it with the word "BOB". Then sets myText to the new text. Then it repeats the process for all items in the variable array.

    Line 6: shows the final edition of the data in myText

    Here are screenshots:

     

     

Content aside

  • 9 mths agoLast active
  • 1Replies
  • 60Views
  • 2 Following