B4J Question String.Replace ( , ) Unexpected Result , Extra Spaces

mangojack

Well-Known Member
Licensed User
Longtime User
When extracting data from a webpage scrape , I have used .Replace to remove portion of string , but the result includes unwanted / unseen spaces.
A manual test works as expected...

'this works as expected ...
B4X:
Dim str As String = $"<td><img src="/images/symbols/large/storm.png" alt="$
str = str.Replace($"<td><img src="/images/symbols/large/"$, "")     'expected result ...  'storm.png" alt='
   
Log($"$|${str}|"$)   'as expected ... '|storm.png" alt=|'



But when run as normal following webpage scrape ...
B4X:
line = TReader.ReadLine       
Log(line)                '   as expected    '<td><img src="/images/symbols/large/storm.png" alt='
line = line.Replace($"<td><img src="/images/symbols/large/"$, "")
       
Log($"$|${line}|"$)      'Not as expected ...    '|     storm.png" alt=|'


I am aware I can include .Trim , but I am curious as to the possible reason or what I am missing.
Using temp strings did not help.

Regards.
 
Top