dimanche 26 janvier 2020

Regex match not returning expected match [duplicate]

The below code is suppose to check if the string starts with $GPXXX where XXX can contain any value in the range [A-Z].

const std::regex nmeaRegex("^\$GP([A-Z]{3})");

if(std::regex_match("$GPLLL", nmeaRegex)) {
  return true;
}

However it does not return true for correct values. Below is a list of values it should match with

$GPLLL
$GPGLL*69
$GPGLL,1,*69

I've tried regex_search too and it still does not work

I've checked this on https://regex101.com/ and it works there.

Aucun commentaire:

Enregistrer un commentaire