Javascript regex. Split string into 4 parts.

Hi,

In javascript I have the following variable:
bounds = "((-37.79235294704733, 144.93249893188477), (-37.78875959854708, 144.93704577956873))"

Open in new window


I need to split each number into its own variable. ie:
a= -37.79235294704733
b= 144.93249893188477
c= -37.78875959854708
d= 144.93704577956873

Open in new window


How can I do this in Javascript? Is this a job for regex?

Thankyou
mhdiAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RobOwner (Aidellio)Commented:
I used a bit of regex but it just saves a few lines:

var bounds = "((-37.79235294704733, 144.93249893188477), (-37.78875959854708, 144.93704577956873))";

var newbounds = bounds.replace(/[\(\) ]+/g,"")
var myarray = newbounds.split(',');

Open in new window


If you were to output the myarray variable:

["-37.79235294704733", "144.93249893188477", "-37.78875959854708", "144.93704577956873"]

in other words you can get each value as myarray[0], myarray[1], myarray[2], myarray[3]

a basic test here:

http://jsfiddle.net/uXsPU/1/
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mhdiAuthor Commented:
Perfect. Thankyou
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.