cut a value of different length

Hello,
I want to change a string (sku) like this:
sku P1011-12-1010-202 is supposed to become P1011-12-1010
this is easily solved with node “string manipulation”: substr ($ sku $, 0, 13)
the problem is, that there are also values ​​that are only 12 digits, e.g.
sku P1011-3-1010-202

the values ​​to be removed are always inclusive of the third “-” below

There are also different variants here, eg.

P1011-3-1010-22
P1011-3-1010-202
P1011-3-1010-1002

P1011-12-1010-22
P1011-12-1010-202
P1011-12-1010-1002

So I only need the value until the third block:
P1011-3-1010
P1011-12-1010

Has anyone got an idea?
Thanks

Dear Nicole,

I always gravitate towards the String Replacer node for these kind of things:

This results in:
result

4 Likes

Thank you so much, it works very well.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.