P Pelky Active Member Licensed User Longtime User Jan 27, 2022 #1 I am trying to replace 5x spaces in a string with a comma "," - I have tried regex and ConvertString.Replace (" ", ",") which I thought would be the easiest way but I am failing. I have a string = "Booth 3 10:00 more guys a948484 23.01.2022" and would like to create an array if anyone can help it would be appreciated...
I am trying to replace 5x spaces in a string with a comma "," - I have tried regex and ConvertString.Replace (" ", ",") which I thought would be the easiest way but I am failing. I have a string = "Booth 3 10:00 more guys a948484 23.01.2022" and would like to create an array if anyone can help it would be appreciated...
behnam_tr Active Member Licensed User Longtime User Jan 27, 2022 #2 B4X: Copy Dim s As String = "Booth 3 10:00 more guys a948484 23.01.2022" Dim ar() As String = Regex.Split(" ",s) For Each m As String In ar Log(m) Next Upvote 0
B4X: Copy Dim s As String = "Booth 3 10:00 more guys a948484 23.01.2022" Dim ar() As String = Regex.Split(" ",s) For Each m As String In ar Log(m) Next
TILogistic Expert Licensed User Longtime User Jan 27, 2022 #3 Replace multiple spaces in a string B4X: Copy Regex.Replace("\s+",s," ") demo: B4X: Copy Dim s As String = "Booth 3 10:00 more guys a948484 23.01.2022" Log(s) Dim ar() As String = Regex.Split(" ",Regex.Replace("\s+",s," ")) Dim sb As StringBuilder sb.Initialize For Each m As String In ar Log(m) sb.Append(m).Append(" ") Next Log(sb.ToString) Upvote 0
Replace multiple spaces in a string B4X: Copy Regex.Replace("\s+",s," ") demo: B4X: Copy Dim s As String = "Booth 3 10:00 more guys a948484 23.01.2022" Log(s) Dim ar() As String = Regex.Split(" ",Regex.Replace("\s+",s," ")) Dim sb As StringBuilder sb.Initialize For Each m As String In ar Log(m) sb.Append(m).Append(" ") Next Log(sb.ToString)
TILogistic Expert Licensed User Longtime User Jan 27, 2022 #4 or B4X: Copy Dim s As String = "Booth 3 10:00 more guys a948484 23.01.2022" Log(Regex.Replace("\s+",s,",")) Upvote 0
or B4X: Copy Dim s As String = "Booth 3 10:00 more guys a948484 23.01.2022" Log(Regex.Replace("\s+",s,","))
TILogistic Expert Licensed User Longtime User Jan 27, 2022 #5 other: B4X: Copy Dim s As String = "Booth 3 10:00 more guys a948484 23.01.2022" Log(Regex.Replace("\s+",s,",")) For Each m As String In Regex.Split(",",Regex.Replace("\s+",s,",")) Log(m) Next Upvote 0
other: B4X: Copy Dim s As String = "Booth 3 10:00 more guys a948484 23.01.2022" Log(Regex.Replace("\s+",s,",")) For Each m As String In Regex.Split(",",Regex.Replace("\s+",s,",")) Log(m) Next