My version is just a variant of what R0j0hound already proposed.
Simply
For "index_name" from 0 to tokencount("text1,text2,text3",",") - 1
--- (condition) tokenat("text1,text2,text3",loopindex("index_name"),",") = "text2"
--- (Action) Collect dictionary: Add key "Index_var" with value loopindex("index_name")
*replace dictionary, index_var, index_name and string as you wanted