I’m having trouble getting rid of ‘repeating’ characters like spaces in a line…
dim s as string = "three spaces two spaces one space"
s = s.ReplaceAll(" ", " ")
Ok… I know I’m pushing my luck but the above code replaces two spaces with one space.
If there are three spaces I want it replaced by 1 space… So I thought replacing two spaces with one would always do the trick… but it don’t.
dim rxSqueezeSpaces as new RegEx
rxSqueezeSpaces.SearchPattern = "\\x20{2,}"
rxSqueezeSpaces.ReplacementPattern = " " // Space
rxSqueezeSpaces.Options.ReplaceAllMatches = true
s = rxSqueezeSpaces.Replace( s )
My M_String module and StringUtils also have pretty fast Squeeze functions. (I think I lifted the one in StringUtils, IIRC.)