Skip to main content
Participating Frequently
November 20, 2009
Question

Strip coordinates from string

  • November 20, 2009
  • 4 replies
  • 830 views

Hello all

Please help. I only need the coordinates from this string

"Latitude: +51.703155 N, Longitude: +5.250327 E http://maps.google.com/maps?q=+51.703155,+5.250327 Sent from my iPhone"

result +51.703155, +5.250327

Does some has an quick solution

THNX

    This topic has been closed for replies.

    4 replies

    Participating Frequently
    November 20, 2009

    OK guys thanks a lot

    I'am a step further

    http://www.teamcapeholland2008.nl/mobmail.cfm

    Inspiring
    November 20, 2009

    OliBBommel wrote on 11/20/2009 5:44 PM:

    OK guys thanks a lot

    I'am a step further

    http://www.teamcapeholland2008.nl/mobmail.cfm

    Why are you asking this on the forums, when you could have gone to the

    ColdFusion User Group meeting in Amsterdam this afternoon and get all

    the help you need in person?

    http://www.cfug.nl/default/index.cfm/agenda/meeting-20-november/?month=11&year=2009&categoryID=&relatedID=

    Participating Frequently
    November 20, 2009

    Jochem

    That was an possibility if I know about this meeting and had some more time

    BKBK
    Community Expert
    Community Expert
    November 20, 2009

    Though it has a different list-index and delimiter, Jochemd's is more efficient. The correct variation is:

    <cfset coordinateStr = "Latitude: +51.703155 N, Longitude: +5.250327 E http://maps.google.com/maps?q=+51.703155,+5.250327 Sent from my iPhone">

    <!--- using ':' or ' ' as delimiter --->
    <cfset latitude = ListGetAt(coordinateStr, 2, ": ")>
    <cfset longitude = ListGetAt(coordinateStr, 5, ": ")>
    latitude: <cfoutput>#latitude#</cfoutput><br>
    longitude: <cfoutput>#longitude#</cfoutput>

    BKBK
    Community Expert
    Community Expert
    November 20, 2009

    <cfset coordinateStr = "Latitude: +51.703155 N, Longitude: +5.250327 E http://maps.google.com/maps?q=+51.703155,+5.250327 Sent from my iPhone">

    treat string as list with delimiter '+' <br>
    <cfset listElement1 = listGetAt(coordinateStr,1,"+")>
    <cfset listElement2 = listGetAt(coordinateStr,2,"+")>
    <cfset listElement3 = listGetAt(coordinateStr,3,"+")>
    <cfset listElement4 = listGetAt(coordinateStr,4,"+")>
    <cfset listElement5 = listGetAt(coordinateStr,5,"+")>
    <br>
    listElement1:<cfoutput>#listElement1#</cfoutput><br>
    listElement2:<cfoutput>#listElement2#</cfoutput><br>
    listElement3:<cfoutput>#listElement3#</cfoutput><br>
    listElement4:<cfoutput>#listElement4#</cfoutput><br>
    listElement5:<cfoutput>#listElement5#</cfoutput><br>

    <!--- then the 2nd, 3rd, 4th and 5th list elements begin with coordinate values --->
    <cfset latitude = "+" & listGetAt(listElement2,1," ")>
    <cfset longitude= "+" & listGetAt(listElement3,1," ")>
    <br>
    latitude: <cfoutput>#latitude#</cfoutput><br>
    longitude: <cfoutput>#longitude#</cfoutput>
    <br>====================================<br>
    treating string as list with delimiter '='<br>
    <cfset listElement = listGetAt(coordinateStr,2,"=")>

    <!--- then the 2nd list element begins with the coordinate values --->
    <cfset coordinates = listgetAt(listElement,1," ")>
    <cfset latitude = listGetAt(coordinates,1)>
    <cfset longitude= listGetAt(coordinates,2)>

    <!--- then the 2nd, 3rd, 4th and 5th list elements begin with coordinate values --->
    <br>
    latitude: <cfoutput>#latitude#</cfoutput><br>
    longitude: <cfoutput>#longitude#</cfoutput>

    Inspiring
    November 20, 2009

    ListGetAt(yourString, 2, ":,") for the lattitude, ListGetAt(yourString, 4, ":,") for the longitude.

    BKBK
    Community Expert
    Community Expert
    November 20, 2009
    @OliBBommel

    result +51.703155, +5.250327

    You marked the following as a solution that produces the above result. It doesn't!

    ListGetAt(yourString, 2, ":,") for the lattitude, ListGetAt(yourString, 4, ":,") for the longitude.