Remove extra spaces from string using the field calculator

Discussion created by namdoogttam on Dec 19, 2011
Latest reply on Nov 13, 2013 by lpinner
Hi, I'm looking for an elegant python expression that I can be used within ArcMap's field calculator to find all instances of consecutive spaces within a string and replace them with a single space.

[INDENT]Let's say in a field called "Address" we have the following value (the product of poor concatenation):[/INDENT]

[INDENT]It should become "123 Main St, Townsville, CA 98463"[/INDENT]

I know that .strip will get rid of the leading/trailling spaces.  How to I get a find/replace approach to continue looping through until all the double-spaces have been reduced to single spaces?  Also, I have tried using .split, but get an error in ArcMap that "Field is not Nullable".

Any help would be appreciated.