I'm in the middle of developing a Twitter app while I need to remove latitude and longitude to parse JSON , Store them in a database and then use them in the Android app. Actually, I managed to get it out, but people were sending their tweets to different devices (iPhone, Blackberry etc.). Here are the examples given to me:
One? T: 51.554644, -0.003976 51.576100, -0.031600 Iphone: 51.554644, -0.003976 Now my question is this: How can I use regular expressions with latitude and longitude, and it's javascript In the form of an array to appear in front of the word that appears in front of it?
You can use something like this:
([0-9 .-] +). + ([0-9.-] Since you have tagged your question with PHP and Javascript, I will show you how to use it in both.
In PHP:
preg_match ('/ ([0-9 .-] +). + ([0-9 .-] +) /', $ str, $ Matches) $ matches = (float) $ matches [1]; $ long = (boat) $ matches [2]; // coors in $ latitude and $ long In JavaScript:
var matches = str.match (/ ([0-9.] +) + ([0-9 .-]) /). Var lat = parseFloat (matches [1] ); Var long = parseFloat (match [2]); // counces are in length and length in Mass For that, there is also Python:
import again match = re match. ([[0-9 .-] +). ([0-9 .-] + ), Str) float (matchgroup (1)) long = float (match.group (2)) # cosons are in latitude and long
Comments
Post a Comment