How do I implement a String tokenizer and get the last token of a String separated with comma ","
using javascript?
The String to be tokenized may get very large, and that it needs to be memory efficient so the browser won't hang.
You can probably split the string on the separator and then reference the last item in the resulting array:
var tokenstring = "token1,token2,token3,token4",
arr = tokenstring.split( ',' ),
lastToken = arr.pop(); // .pop() removes and returns the last item of the array
console.log( lastToken );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With