Pretty basic question. I have a string, it will always be in the format of "(45.234235235,55.345345345)" with variable numbers of decimal places. I want to extract both of these numbers. In PHP I would sscanf, but I want to do this in Javascript.
There is nothing like sscanf, but you can use .replace() and .split():
var data = str.replace(/[()\s]+/g, '').split(',');
Have you heard of the php.js project?
http://phpjs.org/functions/sscanf:886
This is to directly answer your question only. The JavaScript-native way to tackle your problem would be to use regular expressions. See Felix Kling's answer for the proper solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With