How to remove repeating spaces

Bill Vlahos bvlahos at mac.com
Mon Nov 2 19:42:17 EST 2009


Mark and Jim,

Awesome. I knew there had to be an elegant way to do this.

Thank you,
Bill Vlahos

On Nov 2, 2009, at 4:20 PM, Jim Ault wrote:

> On Nov 2, 2009, at 3:54 PM, Mark Schonewille wrote:
>
>> Bill:
>> put replacetext(fld "Spaces","[ ]+"," ") into fld "Spaces"
>>
>> Mark Schonewille
>>
>> On 3 nov 2009, at 00:51, Bill Vlahos wrote:
>>
>>> I want to remove repeating spaces in a field. I can write a brute  
>>> force method but before I do that I'd like to see if someone has  
>>> already invented this wheel.
>>>
>>> Basically all I want to do is reduce all multiple instances of  
>>> spaces in a field to a single space. There could be double,  
>>> triple, or more spaces together and I want to reduce them all to  
>>> just one.
>>>
>>> I can think of a repeating loop that replaces two spaces with one  
>>> and just do it until there aren't any more or do a series of  
>>> replaces four spaces with one, then three spaces with one, then  
>>> two spaces with one but neither of these seem very elegant.
>>>
>>> Bill Vlahos
>
>
> Additionally if you want to remove (trim) single spaces from either  
> side of each line you could add
>
> get fld "Spaces"
> repeat for each line LNN in IT
>   put word 1 to -1 of LNN & cr after newLines
> end repeat
> put replacetext( char 1 to -2 of newLines ,"[ ]+"," ") into fld  
> "Spaces"
>
>
> Hope this helps,
>
> Jim Ault
> Las Vegas
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution

Bill Vlahos
_________________
InfoWallet (http://www.infowallet.com) helps me remember the important  
details of my life.




More information about the use-livecode mailing list