macaskillh
(Macaskillh)
December 20, 2022, 4:51pm
1
Can someone please help me figure out how to remove just the spaces before the commas in a string?
Example:
“25 RIDGEWOOD RD ,SPRINGFIELD ,VT,051560000,015(SVC)”
Looking for:
"“25 RIDGEWOOD RD,SPRINGFIELD,VT,051560000,015(SVC)”
The values in the string between the commas are dynamic.
Anil_G
(Anil Gorthi)
December 20, 2022, 5:15pm
2
@macaskillh
Use this in assign
Str is where i assume the string is stored
str = Str.Replace(" ,",",")
Cheers
1 Like
s0biesky
(Raul)
December 20, 2022, 5:16pm
3
Hi @macaskillh , what about string.replace(“ ,”, ”,”)? It replaces the space and the comma with just a comma.
1 Like
macaskillh
(Macaskillh)
December 20, 2022, 6:37pm
4
I apologize I pasted the wrong value in the example. Here is the correct one:
Example:
“25 RIDGEWOOD RD ,SPRINGFIELD ,VT,051560000,015(SVC)”
This is what I would be looking for:
“25 RIDGEWOOD RD,SPRINGFIELD,VT,051560000,015(SVC)”
Anil_G
(Anil Gorthi)
December 20, 2022, 6:45pm
5
@macaskillh
It looks the same…
But you can use the same provided above to remove space before comma
Cheers
Hi @macaskillh
You can also try on with Regex replace
System.Text.RegularExpressions.Regex.Replace(strvariable,”\s(?=\,)”,””)
Regards
Sudharsan
macaskillh:
25 RIDGEWOOD RD ,SPRINGFIELD ,VT,051560000,015(SVC)
@macaskillh To remove space, just replace space with empty string.
str_input = str_input.Replace(" “,”")
removeSpaces.xaml (4.5 KB)
Gokul001
(Gokul Balaji)
December 21, 2022, 4:39am
8
Hi @macaskillh
You can try with Regex Expression
System.Text.RegularExpressions.Regex.Replace("25 RIDGEWOOD RD ,SPRINGFIELD ,VT,051560000,015(SVC)","\s(?=,)","").ToString
Regards
Gokul
macaskillh
(Macaskillh)
December 21, 2022, 2:56pm
9
This removes the space(s) in the address also, I’m only looking to remove the spaces before the commas.
macaskillh
(Macaskillh)
December 21, 2022, 3:04pm
10
This works exactly as I need, IF I use the exact string but if I replace the string with my variable it only removes one space before the commas.
System.Text.RegularExpressions.Regex.Replace(PMRAddress,“\s(?=,)”,“”).ToString
For some reason when I paste my example the additional spaces are removed. I’ve included a screen shot below showing the variable with the multiple spaces.
Anil_G
(Anil Gorthi)
December 21, 2022, 3:16pm
11
@macaskillh
Please use like this
System.Text.RegularExpressions.Regex.Replace(PMRAddress,"\s+(?=,)","").ToString
This shpuld solve your issue
Cheers
system
(system)
Closed
December 24, 2022, 3:17pm
12
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.