php - Regex for two latitudes and longitudes not working -
i using data gives paths google maps either path or set of 2 latitudes , longitudes. have stored both values blob in mysql database, need detect values not paths when come out in result. in attempt this, have saved them in blob in following format:
array(lat,lng+lat,lng)
i using preg_match find these results, havent managed work. here regex codes have tried:
^[a]{1}[r]{2}[a]{1}[y]{1}[\(]{1}[1-9\.\,\+]{1*}[\)]{1}^ ^[a]{1}[r]{2}[a]{1}[y]{1}[\(]{1}(\-?\d+(\.\d+)?),(\-?\d+(\.\d+)?)\+(\-?\d+(\.\d+)?),(\-?\d+(\.\d+)?)[\)]{1}^
regex confuses me (as doing now). can me out?
edit:
the lat can 2 digits followed decimal point , 8 more digits , lng can 3 digits can 3 digits follwed decimal point , 8 more digits. both can positive or negative.
here example lat lngs:
51.51160000,-0.12766000
-53.36442000,132.27519000
51.50628000,0.12699000
-51.50628000,-0.12699000
so full match like:
array(51.51160000,-0.12766000+-53.36442000,132.27519000)
further edit
i using preg_match() php function match regex.
this regex made:
array\((-*\d+\.\d+),(-*\d+\.\d+)\+(-*\d+\.\d+),(-*\d+\.\d+)\)
this breaks 4 numbers groups can individual numbers.
you note repeated pattern of
(-*\d+\.\d+)
explanation:
-* means 0 or more matches of - sign ( - sign optional) \d+ means 1 or more matches of number \. means literal period (decimal) \d+ means 1 or more matches of number
the whole thing wrapped in brackets make captured group.
Comments
Post a Comment