Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Removing extra spaces in MIDDLE of str.
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00535205
Message ID:
00535704
Views:
14
>>This will remove occurances of multiple spaces.
>>
>>lcStr = ALLTRIM(lcOriginalStr) && remove leading and trailing spaces
>>DO WHILE AT(" ", lcStr) > 0 && look for double space
>> lcStr = STRTRAN(lcStr, " ", " ", 1, 1) && convert double space to single
>>ENDDO
>>
>>I do not know how to get UT to not remove spaces.
>>
>Use < PRE > and < /PRE > tags like this:
lcStr = ALLTRIM(lcOriginalStr)    && remove leading and trailing spaces
>DO WHILE AT("  ", lcStr) > 0       && look for double space
>   lcStr = STRTRAN(lcStr, "  ", " ", 1, 1)  && convert double space to single
>ENDDO
If you hit the reply button, you'll see the actual tags.

Harumph! Can't FoxTools' REDUCE function do this?? I know I can do it with VBScript.RegExp:
oReg = CREATEOBJ('VBScript.RegExp')
oReg.Global = .T.             && FOR ALL OCCURANCES
oReg.Pattern = '\b[\t ]+\b'   && Match any occurance of one or more spaces/tabs
cReducedString = oReg.Replace(cUnReducedString,' ') &&Replace match with ' '
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform