Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Misleading message
Message
 
 
To
19/07/2002 22:42:56
General information
Forum:
Level Extreme
Category:
Other
Miscellaneous
Thread ID:
00680604
Message ID:
00680804
Views:
21
>>>BTW, I'm looking for the best technique to convert the string entered by the user to a one space for each occurence. For example, 4 words might be entered and 3 spaces might appear between the 3rd and 4th word. Basically, it should end up with only one space. I trying to find the best approach but there seems to be a lot of variations of such implementation.
>>
>>See Re: Removing embedded spaces Message #561050
>
>Yup, quite useful, this is the approach I was expecting. I was trying to find another way than DO While, but I guess, this is the best to resolve that issue. Thanks

If you're looking for a one-liner, here's one.
lcStr = "This    is a    string                with  spaces"
? EVALUATE(REPLICATE([STRTRAN(], CEILING(LEN(lcStr) / 2)) + [lcStr] + ;
			REPLICATE([, SPACE(2), SPACE(1))], CEILING(LEN(lcStr) / 2)))
I think that you can replace
CEILING(LEN(lcStr) / 2)) 
* with 
CEILING(SQRT(LEN(lcStr)))
* or even better
CEILING(SQRT(OCCURS(SPACE(1),lcStr))))
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform