Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to compress space in string?
Message
De
23/05/2003 04:55:15
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Allemagne
 
 
À
23/05/2003 04:39:58
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00792083
Message ID:
00792099
Vues:
19
Hi Greg,
no it does'nt. ::(.

Try a = '12......34...56...'
Return is 12..34.56. not 12.34.56. as expected.

I know I can do something like
a = '12......34...56...6..5.'
DO WHILE !EMPTY(OCCURS('..',a))  
 a=STRTRAN(a,'..','.')
ENDDO &&!EMPTY(OCCURS('..',a))
?a
but I search for something without loop.

Agnes

>Agnes,
>
>Does this work ? Replace the dots with spaces
>
>
>
>a = '12...34...56...'
>? StringSearchAndReplace(a, '..', '.')
>
>*-------------------------------------------------------------------------------
>function StringSearchAndReplace(Searched, SearchFor, ReplaceWith, IgnoreCase)
>
>	local i, Offset, SearchForLength, ReplaceWithLength
>	
>	SearchForLength = len(SearchFor)
>	ReplaceWithLength = len(ReplaceWith)
>	Offset = 1
>	
>	do case
>	case IgnoreCase
>		i = atc(SearchFor, substr(Searched, Offset))
>		do while !empty(i)
>			i = i + Offset - 1
>			Searched = stuff(Searched, i, SearchForLength, ReplaceWith)
>			Offset = Offset + ReplaceWithLength
>			i = atc(SearchFor, substr(Searched, Offset))
>		enddo
>	otherwise
>		i = at(SearchFor, substr(Searched, Offset))
>		do while !empty(i)
>			i = i + Offset - 1
>			Searched = stuff(Searched, i, SearchForLength, ReplaceWith)
>			Offset = Offset + ReplaceWithLength
>			i = at(SearchFor, substr(Searched, Offset))
>		enddo
>	endcase
>	
>	return Searched
>endfunc
>*--------------------------------------------------------------------------
>
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord

Weeks of programming can save you hours of planning.

Off

There is no place like [::1]
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform