Elimate extra spaces from string

Hello Team,
i have 2 strings;

  1. Hello Xyz How are you
    2)Hello PQR How are you

How can we remove extra whitespaces from these strings,
Please guide

i guess editor is not allowing me to insert extra whitespaces,
i want to know if the whitespaces between words are not fixed and if i want to remove those.

Just create an assign activity lets 1 is A and 2 is B

A=A.Replace(" “,”")

IT works as i have told you below no matter the number of spaces it has between words…

Hello,Thanks for you reply,

Expected OP: Hello XYZ How are you?

Then do the A.Replace(Environment.NewLine,"")

Can you send me workflow,im not getting you

The following will remove space at the beginning and the end of MyString and will limit any space sequence inside to one space only.

MyString = System.Text.RegularExpressions.Regex.Replace(MyString.Trim, "\s+", " ")

1 Like

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