0

i need to get number with sign from a string.

eg:

-675.5+987.5i
+675.5-987.5i 

output:

-675.5

+987.5

+675.5

-987.5
1
  • 1
    Accept your recent questions. Commented Apr 5, 2011 at 8:55

1 Answer 1

3
var numbers = "-675-987i".match(/[-+]\d+(\.\d+)?/g);

Edited to handle also plus sing and float value.

Sign up to request clarification or add additional context in comments.

4 Comments

var number ="-675.5-987.7i" ---> output=-675.5,-987.7
It returns an array - just handle it as an array :)
var number=this.match(/(-|\+)?\d+\.?\d*/g) get the output thanks a lot
@Tarun if this was what you're after please click the "V" icon to the left to Accept this answer as correct. If for your own reasons you insist on not doing so it's your choice but people will simply stop helping you in this place.

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.