Remove the first character of the string based on length

Hello everyone,

I am trying to eliminate a leading character (‘3’ in this case) if the length of the ID is 11 character long.
So,
31000000000 needs to be 1000000000 as 31000000000 has 11 characters
but, 3100000000 will stay the same as it has only 10 character.

Can anyone suggest me how I can do that?

Hi @Arif2021

You can use a StringManipulation node. Reverse the inputstring, take a substring (length 10) from this reversed string, and reverse it back to its original order.

reverse(substr(reverse($column1$),0 ,10 ))

gr. Hans

4 Likes

Hi @HansS,
Wow, this is a really elegant solution! Just note that this does not work if the string can also be more than 11 characters and in that case should stay as-is as well.
Alexander

1 Like

Hi @AlexanderFillbrunn

Tnx :slight_smile:

But, I’m having trouble understanding what you mean by the comment below. :thinking:

This how the output looks like.


gr. Hans

Hi Hans,
The criterium is: “if the length of the ID is 11 character long.” But you are handling it like “is 11 characters or longer”
Alexander

1 Like

Hi @AlexanderFillbrunn

Ah, now I see what you mean. Well in that case a RowSplitter(s) before and Concatenate node after will be helpful. Looking forward to your feedback @Arif2021 .
gr. Hans

1 Like

Hi @HansS, @AlexanderFillbrunn,

Apologies for the late response guys. Thank you so much for the solution - this is exactly what I was looking for! It worked perfectly!

Alex, I will keep your comment in mind but as of right now 11 characters are the max, which might change in future. But, a good suggestion regardless.

1 Like

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