Now I have a widget with an oh-repeater component and would like have the string before the parameter Zustand to then get the fitting Element for LetztesUpdate.
But because the items have a different amount of seperators (“_”), which I need in this case, I can’t use my normal method to build the string via:
If you know that the starting item will always end in _Zustand then you can just use the string method slice to remove the last 8 characters of the string:
loop.item.name.slice(0,-8)
If you have variable length suffixes on the item name then you can use split and then slice the last element off of the array and re-merge the elements with join:
loop.item.name.split("_").slice(0,-1).join("_")
You can also use lastIndexOf as in @rlkoshak’s answer, but there is no assignment in widget expressions so you’d have to combine that into one expression: