Unknown space in text

An unknown space/tab character in the text. After inserted into the database , it becomes a normal space.
But the problem is that i gotta take the text from the database and compare to this text for difference. If there is difference, insert into the database. else just leave it. But everytime i run, it has a difference and it is the same space/tab problem. I tried replace tab to a single space, or replacing 2 spaces with a single space and it doesnt work.
The point is this text will be extracted from another system. so i cant change it.

The below code is what i used:

str = System.Text.RegularExpressions.Regex.Replace(System.Text.RegularExpressions.Regex.Replace(str.ToString.Replace("‟","'").Replace(vbtab+Environment.NewLine, " "+environment.newline).Replace(" "+ Environment.NewLine, environment.newline).Replace("\",environment.NewLine), " {2,}", " "), "TAB", "").ToString

This is the example text:

This is bad The space is just after this sentence’s full stop and before today’s date, I just cant seem to get rid of it, which ive been spending too much time on.
15 Apr 2021
Hello Testing 123.
16 Apr 2021

Try below

varStr.Trim.Replace("  "," ")

tried is still the same

Hi, try this:

output = System.Text.RegularExpressions.Regex.Replace(your_String, "\s{2,}" , " ")

output = String
your_String= String

Preview link: regex101: build, test, and debug regex

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