Tarun
Tarun

Reputation: 13

Regular Expression Javascript

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

Upvotes: 0

Views: 109

Answers (1)

hsz
hsz

Reputation: 152206

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

Edited to handle also plus sing and float value.

Upvotes: 3

Related Questions