[Never Mind] ReplaceString Not Working

Just starting out? Need help? Post your questions and find answers here.
Randy Walker
Addict
Addict
Posts: 1109
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

[Never Mind] ReplaceString Not Working

Post 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
Last edited by Randy Walker on Fri Apr 25, 2025 6:58 pm, edited 1 time in total.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
User avatar
Piero
Addict
Addict
Posts: 1040
Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy

Re: ReplaceString Not Working

Post by Piero »

Code: Select all

ReplaceString(ip$,"ssh2 ","")
works on Mac
normeus
Enthusiast
Enthusiast
Posts: 475
Joined: Fri Apr 20, 2012 8:09 pm
Contact:

Re: ReplaceString Not Working

Post 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
google Translate;Makes my jokes fall flat- Fait mes blagues tombent à plat- Machte meine Witze verpuffen- Eh cumpari ci vo sunari
Marc56us
Addict
Addict
Posts: 1600
Joined: Sat Feb 08, 2014 3:26 pm

Re: ReplaceString Not Working

Post 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$
User avatar
NicTheQuick
Addict
Addict
Posts: 1527
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: ReplaceString Not Working

Post 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.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
BarryG
Addict
Addict
Posts: 4219
Joined: Thu Apr 18, 2019 8:17 am

Re: ReplaceString Not Working

Post 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.
infratec
Always Here
Always Here
Posts: 7662
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: ReplaceString Not Working

Post 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)
Randy Walker
Addict
Addict
Posts: 1109
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Re: ReplaceString Not Working

Post 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. :twisted:
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.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Post Reply