Replace All, Loop?
Hi , I 'm playing with OpenAI Assistants API . I have read we are not doing loops in Toddle , but I can 't get the logic of how to solve this case . What I don 't understand I need to iterate over , or "know " how to replace all instances in a string , with new data , based on another array . I have a string : Hello [text _1 ] this is a string . [text _2 ] I have an array (simplified example ) : [ { "text " : " [text _1 ] " } , { "text " : " [text _2 ] " } I want to replace [text _1 ] with " [0 ] " and [text _2 ] with " [1 ] " . (Use index for now , maybe something else later ) Desired result : Hello [0 ] this is a string . [1 ] Any ideas ? Try using Split rather than Replace All and have the [ 4 :3 . . . . ] text as the delimiter . This will generate an array of the text with each section broken down into an element at each instance of [4 .3 . . . ] . You can then map it to generate an array with the text and the index . The numbers /string inside the [ ] does vary ; so I will not have a fixed delimiter . If we had loop , I would think it could look like this : For each item in array ie . (item = [text _1 ] ) , Find and replace [text _1 ] in STRING , with item .index This is just for the initial testing I think . In the end i will probably do this in the backend , but right now I 'm using API /response for MVP .