Page 1 of 1
[Never Mind] ReplaceString Not Working
Posted: Fri Apr 25, 2025 7:24 am
by Randy Walker
Normally i think it would be me but I can't see anything wrong here:
Code: Select all
ip$ = " ssh2 192.28.26.189"
s$ = ReplaceString(ip$,"ssh2 ","zebras")
Debug s$
Where are the zebras?
This is what I was actualy trying to do, to just remove ssh2:
Code: Select all
ip$ = " ssh2 192.28.26.189"
s$ = ReplaceString(ip$,"ssh2 ","")
Debug s$
Fails here in PB 5.40 and PB 6.20
Re: ReplaceString Not Working
Posted: Fri Apr 25, 2025 7:42 am
by Piero
Re: ReplaceString Not Working
Posted: Fri Apr 25, 2025 8:03 am
by normeus
It works with pbx64 and Win11. Could it be the space you have at the end of the search string "ssh2 "
maybe there is no space in the string to be searched
Code: Select all
ip$ = " ssh2 192.28.26.189"
s$ = Trim(ReplaceString(ip$,"ssh2",""))
Debug s$
try no spaces then Trim
norm
Re: ReplaceString Not Working
Posted: Fri Apr 25, 2025 8:25 am
by Marc56us
Randy Walker wrote: Fri Apr 25, 2025 7:24 am
Normally i think it would be me but I can't see anything wrong here:
Code: Select all
ip$ = " ssh2 192.28.26.189"
s$ = ReplaceString(ip$,"ssh2 ","zebras")
Debug s$
Where are the zebras?
This is what I was actualy trying to do, to just remove ssh2:
Code: Select all
ip$ = " ssh2 192.28.26.189"
s$ = ReplaceString(ip$,"ssh2 ","")
Debug s$
Fails here in PB 5.40 and PB 6.20
Both works PB 5.46 and PB 6.21 B6
PS. Why not use RemoveString() ?
Code: Select all
t$ = RemoveString(ip$, "ssh2 ")
Debug t$
Re: ReplaceString Not Working
Posted: Fri Apr 25, 2025 8:29 am
by NicTheQuick
It definitely works fine here.
My assumption is that there might be not a real space in the string but after copying it into the forum it got fixed automatically.
Re: ReplaceString Not Working
Posted: Fri Apr 25, 2025 9:27 am
by BarryG
Randy Walker wrote: Fri Apr 25, 2025 7:24 amFails here in PB 5.40 and PB 6.20
Works here in 6.20.
Re: ReplaceString Not Working
Posted: Fri Apr 25, 2025 9:35 am
by infratec
use this
Code: Select all
ip$ = " ssh2 192.28.26.189"
ShowMemoryViewer(@ip$, StringByteLength(ip$))
And check if there is a 20 00 after the 2 (32 00)
Re: ReplaceString Not Working
Posted: Fri Apr 25, 2025 6:56 pm
by Randy Walker
Marc56us wrote: Fri Apr 25, 2025 8:25 am
Both works PB 5.46 and PB 6.21 B6
PS. Why not use RemoveString() ?
Code: Select all
t$ = RemoveString(ip$, "ssh2 ")
Debug t$
Damned computers.
Tried again this morning in PB 5.40 and PB 6.20 -- both worked fine.

Thanks for the removestring tip. I didn't know it was even there and it works great too.