add a flag to replace ReplaceString 3=ALL

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Fangbeast.

Hi Fred, could you add a flag to ReplaceString to allow replacement of ALL occurences in a string, not just the default ANY, which I assume would be the first possible match?

Regards (you did say you wanted more suggestions) :)

Fangles
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.

ReplaceString() already work like that no ?

Fred - AlphaSND
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Fangbeast.
Hi Fred, could you add a flag to ReplaceString to allow replacement of ALL occurences in a string, not just the default ANY, which I assume would be the first possible match?

Regards (you did say you wanted more suggestions) :)

Fangles
As far as I can tell, it replaces the first found occurence only but I shall do more tests after today.

Fangles
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

> As far as I can tell, it replaces the first found occurence only

No it doesn't... try this:

Code: Select all

s$="THIS, THIS and THIS will be replaced"
Debug ReplaceString(s$,"THIS","GONE")

PB - Registered PureBasic Coder
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Fangbeast.
> As far as I can tell, it replaces the first found occurence only

No it doesn't... try this:

Code: Select all

s$="THIS, THIS and THIS will be replaced"
Debug ReplaceString(s$,"THIS","GONE")
PB - Registered PureBasic Coder
Yes, I finally got time to play with it and figure it out, was using my own custom routines before. ReplaceString has managed to make me slim my code down a bit.

Now, if only I could find an easy way to figure out what darned thing keeps stealing focus from my listicongadget and life would be peachy :)

Fangles
Post Reply