0

I'm parsing text file using Javascript. On the lines I have slice() function, my code appear to behave differently on local host and online

for example

if(connection == 'local') {
     value = d.substring(split2, split3).substr(1).slice(0, -1);
}
else if(connection == 'online') {
     value = d.substring(split2, split3).substr(1);
}

However this piece of code solve it but I cannot understand the behavior, it seems like when I use my code online that are extra hidden characters on the text file or something

zEn feeLo
  • 1,877
  • 4
  • 25
  • 45

1 Answers1

0

you can do

value = d.substring(split2, split3).substr(1).trim(); 

trim() should remove any spaces and Escape Sequences.

  • some Escape sequences are hidden when you tries to debug your app, for example if you have `"\rfoo"` it will be shown as `"foo"` but actually it's not. – Tariq Mamdouh Jun 07 '21 at 00:27
  • yes I think its about \r but whats the difference between localhost and online server? – zEn feeLo Jun 07 '21 at 00:38