Delete part of string

So my Problem is, I have Strings from an Excel sheet and most of them are of the same form: 000###### and i would like to remove the 000 at the beginning. Any ideas?
Also some are without the 000 so i need to use an if decision.

1 Like

@plmrsch,

Welcome to UiPath Community!.

You can do this in an Assign Activity as the below one, you need to loop the excel rows using Foreach Row activity and then you need to place this assign inside that.

Untitled

1 Like

Thanks for the awnser, but i would like the variable to stay the same.
I thought something like this (see picture) might work but i dont know what the Expression in the if statement needs to be to see if the variable even has the 000 and also how to get rid of the 000 with write a line or something like it

Hi
Welcome to uipath community
We may not be sure like how many zeros will come in Front Or those three zeros might come in middle or at last
So use Regex in this case like this with a assign activity
stroutput = System.Text.RegularExpressions.Regex.Replace(strinput.ToString,”^[0]+”,””).ToString.Trim

Cheers @plmrsch

1 Like

Hi, thanks! But again is there any way so i dont have to initiate a new variable and can just update the old one? :slight_smile:

1 Like

Yah simple
Like this
strinput = System.Text.RegularExpressions.Regex.Replace(strinput.ToString,”^[0]+”,””).ToString.Trim

Same variable on either sides of assign activity
Cheers @plmrsch

Use the following condition in IF -

If Personalnummer.SubString(0,3) = "000" Then
       //if personalnummer contains 000 at the start
       //use the following expression to replace 0's at the start and store it in strResult
       strResult = Personalnummer.SubString(3)
Else
      //if personalnummer doesn't contain 000 at the start
End If

Regards,
Karthik Byggari

1 Like

Yeah, awsome thanks!

1 Like

String.replace(“000”,"")
after this string.trim

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