myString.match(/(lon:)/g)
^-{0,1}((180|180.[0]{1,20}|[0-9]|([0-9][0-9])|([1][0-7][0-9]))|(179|[0-9]|([0-9][0-9])|([1][0-7][0-9]))[.]{1}[0-9]{1,20}){1}$
^-{0,1}((90|90.[0]{1,20}|[0-9]|[1-8][0-9])|(89|[0-9]|[1-8][0-9])[.]{1}[0-9]{1,20}){1}$
var shortString = "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>"; var myArray = shortString.match(/lat:-{0,1}((90|90.[0]{1,20}|[0-9]|[1-8][0-9])|(89|[0-9]|[1-8][0-9])[.]{1}[0-9]{1,20}){1}/g); alert(myArray[0]);
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:" usingmyString.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