oxygen_728
asked on
VB.NET - Regex - Need to replace all occurances of Multiple Space Chars with one space
Hi.
I need to replace multiple consecutive space characters with a single space character.
For example:
"A B C " becomes: "A B C "
" A B C D" becomes " A B C D"
Any tips?
Thanks
I need to replace multiple consecutive space characters with a single space character.
For example:
"A B C " becomes: "A B C "
" A B C D" becomes " A B C D"
Any tips?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Here's what I came up with that uses josgood's solution
StrippedResults = System.Text.RegularExpress ions.Regex .Replace(S trippedRes ults, "([ |\n|\t|\f][ |\n|\t|\f]+)|([\n]{1})", " ")
It does the following:
'This replaces all multiple occurances of spaces,tabs,line breaks, form feeds with a single space
'It also replaces single line breaks with a space
StrippedResults = System.Text.RegularExpress
It does the following:
'This replaces all multiple occurances of spaces,tabs,line breaks, form feeds with a single space
'It also replaces single line breaks with a space
Open in new window