How to remove white spaces in string and trim

Hello Guys
i have string like “DEMO - Sliced Invoices|||||||||||||||||||||||||||||||||||||||||||||||Order Number|||||||||||12345”

“|=white spaces”

Here my idex value for this is “Demo=0”, “-=1”, “Sliced=2”, “Invoices=3” and “Order=52” so on

and i want to be as
“Demo - Sliced Invoices=1”
“Order number=2”
“12345=3” as INDEX values

Fine
this exxpression would do that
str_output = System.Text.RegularExpressions.Regex.Replace(str_input,"[\s]","")

Cheers @Pradeep_Shiv

3 Likes

try to use string.replace method @Pradeep_Shiv

its showing as Demo-slicedinvoicesordernumber12345

and if i give i index value 0 im getting the same if index value 1 out of boundry

how can i get like
index value 0 = Demo-Slice Invoices
index value 1 = Order Number
Index value 2 = 12345

1 Like

got it
if this is the input
str_input = “DEMO - Sliced Invoices|||||||||||||||||||||||||||||||||||||||||||||||Order Number|||||||||||12345”

then
str_output1 = system.text.regularexpressions.regex.matches(str_input,"[^|]+")(0).ToString
str_output2 = system.text.regularexpressions.regex.matches(str_input,"[^|]+")(1).ToString
str_output3 = system.text.regularexpressions.regex.matches(str_input,"[^|]+")(2).ToString

Cheers @Pradeep_Shiv

1 Like

str_output1 = D
str_output2 = E
str_output3 = M

This is the output

its working fine for me
here you go
regex.zip (9.3 KB)

Cheers @Pradeep_Shiv

that “|” is Blank space if you have mistaken sorry!!!

Fine
“DEMO - Sliced Invoices|||||||||||||||||||||||||||||||||||||||||||||||Order Number|||||||||||12345”
will this string remain the same except the order number value or will it differ

@Pradeep_Shiv

it may in other array of strings

Hi @Pradeep_Shiv

If you know that there will always be multiple spaces between your text elements, you can use

regex.Split(demoString,"\s{2,}")(0)
regex.Split(demoString,"\s{2,}")(1)
regex.Split(demoString,"\s{2,}")(2)

Cheers.

Troy

1 Like

pls find the xaml attached
pradp.zip (39.3 KB)

kindly try this and let know for any queries or clariffication
Cheers @Pradeep_Shiv

1 Like

Cheers @Pradeep_Shiv
pradpp.zip (49.7 KB)

1 Like

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