0

is it possible to get the last value of an string, that looks like this for example:

tm="1610612741|Bulls|Chicago|CHI"

and save it as a variable?

Something like that:

var tm = $(this).find('htm').attr('tm');

I only need the "CHI" string. I tried everything, but what i found doesnt work. I get the string and the var from an xml file. Also is it possible to parse the xml from a "live" version, like http://www.exampledomain.com/test.xml?

Appreciate your help!

Nicole

1 Answer 1

1
var tm = '1610612741|Bulls|Chicago|CHI';
var arr = tm.split('|');
var lastPart = arr[arr.length - 1];

alert(lastPart); // CHI
Sign up to request clarification or add additional context in comments.

2 Comments

wow thank you, it works perfectly. almost what i got, but i guess i got confused, still learning :) thank you!
Great! Please mark my solution as the answer if that is the case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.