String formation Issue


#1

I have below string along with multi tabs which needs to be separated by single space and please note no line breaks or space should not be present in the new string :

actual string :
always space at the beginning
space here 0000000 tabs here (1 or 2 or three) 01 again tabs here 0000111.00 again tabs here 0000000 02 0000444.00
0000000 03 0000111.00 0000000 04 0000333.00
0000000 05 0000999.00 0000000 06 0000222.00
0000000 07 0000888.00

Resulted string : no space
0000000 01 0000123.00 0000000 02 0000124.00
0000000 03 0000126.00 0000000 04 0000127.00
0000000 05 0000129.00 0000000 06 0000130.00
0000000 07 0000145.00


#2

Please check attached xaml, let me if that’s what you need.

stringspace.xaml (5.7 KB)


#3

Thanks above regex removed the space as well line break. But I need the line breaks - for example here I want 4 rows but no spaces which is already removed. Once again placing the data here :

0000000 01 0000123.00 0000000 02 0000124.00
0000000 03 0000126.00 0000000 04 0000127.00
0000000 05 0000129.00 0000000 06 0000130.00
0000000 07 0000145.00


#4

This regex should work.

strInput = " 0000000 01 0000111.00 0000000 02 0000444.00"+Environment.NewLine+“0000000 03 0000111.00 0000000 04 0000333.00”+Environment.NewLine+“0000000 05 0000999.00 0000000 06 0000222.00”+Environment.NewLine+“0000000 07 0000888.00”

regex.Replace(strInput.Trim,"[^\S\r\n]+"," ")


#5

Thanks this works