Remove comma from start of the string

Hi I have a doubt to remove a comma from string
string is “,name”
It should be just “name”
Used trimstart option. it didn;t work
any help?

Use the replace function, like str.replace(“,”,“”)

Hi
actually the string is “,name,name2,name3”
so if I use replace it removes all the commas
so I just want the 1st comma before name should be removed

You could use an if activity to check if the string starts with a comma.

str_Var.StartsWith(“,”) = True
Then, str_Var.Substring(1)

This will drop the first character, the comma, from the string.

It is providing the same result with comma. No changes using the above solution.

Any other easy option available?

You can try using Regex with this pattern and an Assign activity.

Left side of Assign
Str_CleanStringResult

Right side of Assign
System.Text.RegularExpressions.Regex.Matches(INPUT_STRING_VARIABLE,“^\,”)(0).ToString

Hopefully this helps :slight_smile:

Does the string always start with “,”? if is so, try str = str.subString(1,str.Length())

Can you post the code you are using?

Hi,

Used trimstart option. it didn;t work

Can you try TrimStart Method as the following?

yourString.TrimStart(","c)

img20211013-1

Regards,

1 Like