I'm working with latlon values for YM4R with google maps. I need to know how to split a string after 10 characters.
Here is an example string "51.5261658-0.0810102" if I know split the string after the 10th character开发者_运维百科, I would be able to get separate lat lon values.
Has anyone got any ideas?
Why not just split on the -
?
str = "51.5261658-0.0810102"
values = str.split("-")
lat = values[0]
lon = values[1]
Here we slice off the first 10 characters
str = "51.5261658-0.0810102"
#remove the - if it's there
str.gsub!("-","")
lat = str.slice!(0..9)
lon = str
精彩评论