Ad Widget

Collapse

GPS Coordinates regular expressions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • markfree
    Senior Member
    • Apr 2019
    • 868

    #1

    GPS Coordinates regular expressions

    I'm getting some simple GPS coordinates from a script that output something like this:
    Code:
    -75.93367886,-126.94287288
    To read that I created an item that reads the script output. Below it, there are 2 dependant items, one for latitude and another for longitude.

    For each dependant item, I thought of pre-processing that raw value using some regular expressions, but I just can't figure out how to do it.

    Any tips?
  • atousled
    Junior Member
    • Mar 2021
    • 4

    #2
    Helo, (-\d+\.\d+) for lat and (?<=,\ )(-\d+\.\d+) for lon. gl

    Comment

    • markfree
      Senior Member
      • Apr 2019
      • 868

      #3
      That works great.
      Just as expected.
      Thanks a lot.

      Comment

      • cyber
        Senior Member
        Zabbix Certified SpecialistZabbix Certified Professional
        • Dec 2006
        • 4807

        #4
        It is as it is said on a page you followed
        [quote=atousled]Helo, (-\d+\.\d+) for lat and (?This will work only for coordinates starting with "-"..
        Both dependant items can use same regex "(.*),(.*)" and one uses \1 for output and other \2
        Last edited by cyber; 24-12-2021, 12:36.

        Comment

        • brantpeter
          Junior Member
          • Oct 2023
          • 3

          #5
          You can use regular expressions like this for latitude and longitude extraction: Latitude: (-?\d+\.\d+), Longitude: (-?\d+\.\d+).


          Comment

          Working...