When I Try To Parse By Js Split The First Element Is Empty String
I try to parse ini file, the first string is empty string, but others okay: Structure: [sensor1] param1: value [sensor2] param1 : value param2 : value And my code is: success
Solution 1:
To remove the empty result at index 0:
vararray = 'abcdef'.split('a');
array.shift() // Removes first element from array.
How split(1)
works:
Index 0: everything before the matching seperator
Index n: The nth result after the matching seperator until the next occurence of the matching seperator or endofstring
.
Since there is nothing before your first match since your first match occurs right at the start of the string, your first element in your array is an empty string.
For a detailed documentation about split() take a look at the Mozilla-Docs: (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)
Post a Comment for "When I Try To Parse By Js Split The First Element Is Empty String"