Page 1 of 1
[Implemented] ReplaceString: Add opt. para. [,NbOccurences]
Posted: Wed Apr 14, 2010 2:47 pm
by IceSoft
String$ = ReplaceString(String$, StringToFind$, StringToReplace$ [, Mode [, StartPosition]])
I cannot say: Replace only the first occurence of a search string.
Re: ReplaceString has no parameter for NbOccurences
Posted: Wed Apr 14, 2010 3:33 pm
by Fred
Where is the bug ?
Re: ReplaceString has no parameter for NbOccurences
Posted: Wed Apr 14, 2010 7:10 pm
by IceSoft
ReplaceString iterating trough the whole string...I miss the occurence parameter for stopping the iteration e.g. after the first replace
Code: Select all
s1.s = "abcdeabcdeabcdeabcde"
s2.s = "ab"
Debug s1
String$ = ReplaceString(s1, s2, "AB" , #PB_String_InPlace, 1)
Debug s1 ; Result: ABcdeABcdeABcdeABcde, but I want: ABcdeabcdeabcdeabcde
ReplaceString have also have to have the NbOccurences parameter as the RemoveString has:
Code: Select all
String$ = RemoveString(String$, StringToRemove$ [, Mode [, StartPosition [, NbOccurences]]])
Re: ReplaceString has no parameter for NbOccurences
Posted: Wed Apr 14, 2010 7:28 pm
by Arctic Fox
Isn't this a feature request then?

Re: ReplaceString has no parameter for NbOccurences
Posted: Wed Apr 14, 2010 7:54 pm
by IceSoft
Arctic Fox wrote:Isn't this a feature request then?

Yes for all who not using ReplaceString at the moment.
If you use it...than it is a bug.
Re: ReplaceString has no parameter for NbOccurences
Posted: Wed Apr 14, 2010 7:55 pm
by Rings
moved....
Re: ReplaceString has no parameter for NbOccurences
Posted: Wed Apr 14, 2010 8:01 pm
by IceSoft
Rings wrote:moved....
Please add this optional parameter. You know: it is more a wrong design as a feature wish.
Re: ReplaceString has no parameter for NbOccurences
Posted: Wed Apr 14, 2010 9:20 pm
by freak
Just because you want it doesn't make it wrong not to have it

Re: ReplaceString has no parameter for NbOccurences
Posted: Wed Apr 14, 2010 9:21 pm
by Seymour Clufley
+1
Re: ReplaceString has no parameter for NbOccurences
Posted: Wed Apr 14, 2010 9:47 pm
by IceSoft
freak wrote:Just because you want it doesn't make it wrong not to have it

In a real programmer life I can find more examples on which you want ONLY replace one occurence.
So my wish is:
Add a ReplaceString which is not searching through a string...a replace on a given position is enough.
For the actual implemented ReplaceString... please add the forgotten optional parameter:[, NbOccurences].
For example see RemoveString(...):
String$ = RemoveString(String$, StringToRemove$ [, Mode [, StartPosition [, NbOccurences]]])