Need to remove empty commas

If i get the input like this ina variable

,2019

Output should be 2019

Input2

2022,2023,2019

Output should be
2022,2023,2019

Input 3

2022,2023,2019,

Output should be
2022,2023,2019

Need to remove empty commas

Hi @sruthesanju

You can use the following:

strValue.trim(","c)

Here, strValue is the string variable in which the value is stored.

Edit: Verify the TRIM function

image

Hope this helps,
Best Regards.

@sruthesanju

You can use this

Str.TrimEnd(","c).TrimStart(","c)

Cheers

Hi @sruthesanju

Please try this

yourStringVariable.TrimStart(",“c).TrimEnd(”,"c)

Hey @sruthesanju
Hope this will help

image

String trim.zip (68.4 KB)

Cheers.

1 Like

Hi @sruthesanju

Try this

Test.zip (2.7 KB)

image

Hope this might help you :slight_smile:

If my input is ,2019,2019

Output should be 2019,2019

But i am getting result as 2019,2019

Hey @sruthesanju

Output should be 2019,2019

But i am getting result as 2019,2019

What is the difference in this can you specify its the same right ?

Do you mean you want to remove the comma in between also ?

Yes between as commas need to remove

Hey @sruthesanju ,
Just give a try to this

RemoveCommas.zip (1.7 KB)

image

Regards,

Hey @sruthesanju
Is this what you want
image

image
You can use this.

Cheers.

1 Like

Getting error in opening the code can you share the pic of the code

@sruthesanju
Check this


image

Regards,

@sruthesanju

Please try this

System.Text.RegularExpressions.Regex.Replace(str.Trim(","c),",{2,}",",")

image

cheers

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