regexnmeaais

Regex to Search AIS NMEA Sentence


What is regex to search and validate AIS NMEA sentences?


Solution

  • According to https://gpsd.gitlab.io/gpsd/AIVDM.html, a safe bet that any such sentence containing an A or B channel code in field 5 is AIVDM/AIVDO.

    For now, I am using regex

    [A-Z] \w+,\d,\d,(?:\d{1}|),[A-B],[^,]+,0\*([A-Za-z0-9]{2})

    Hope this helps.