0

I have

var abcd = "matrix(1,0,0,1,114.0,256.4)"

as an String i want last digit (i.e 256.4 This may change to any other number like 256.45) Can it be possible to get that number?

1
  • 3
    abcd.match(/[\d.]+\)$/)? Commented Jul 17, 2014 at 8:55

2 Answers 2

2

I think this is a good task for regular expressions, try this:

abcd.match(/([\d.]+)\)$/)[1]
Sign up to request clarification or add additional context in comments.

Comments

1

Try this:

var abcd = "matrix(1,0,0,1,114.0,256.4)";
var result = abcd.split(",");
result = result[result.length - 1];
result = result.slice(0, - 1);
alert(result); // 256.4

Working demo.

Comments

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.