ctalleygreenville

Regular expression to extract lat lon from string

Discussion created by ctalleygreenville on Mar 15, 2011
Latest reply on Mar 15, 2011 by ctalleygreenville
Hello all,

This has to be easy, but I cannot seem to form the expression correctly.  How can I extract the actual longitude value from the following web query (is a text string at the point where I am wanting to extract)?

Vehicle ID:truck1 lat:34.833730000000003 lon:-82.352369999999993 dir:90.0 spd:0.0 lck:6 time:151842 date:03142011 trig:2 eof<br>

I can match "lon:" using
myString.match(/(lon:)/g)
but I cannot seem to get the portion associated with the value.  I need -82.352369999999993 or lon:-82.352369999999993

The number of digits for the longitude is not always the same, but it is always followed by a space then dir:


Thanks in advance.

Carmen

Outcomes