Regex MAC address – Programming Questions

Hey guys,

I want to use the Regexp library to check if a MAC address could be valid, is that possible and can I use the standard Regex formula for that?

void loop() {
  MatchState ms;
  int packetSize = UDP.parsePacket();
  if (packetSize)
    // receive incoming UDP packets
    Serial.printf("Received %d bytes from %s, port %drn", packetSize, UDP.remoteIP().toString().c_str(), UDP.remotePort());
    int len =, 255);
    if (len > 0)
      incomingPacket[len] = 0;
    ms.Target (incomingPacket);
    char result = ms.Match ("^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$"); 
    Serial.printf("UDP packet contents: %sn", incomingPacket);

    // send back a reply, to the IP address and port we got the packet from
    UDP.beginPacket(UDP.remoteIP(), UDP.remotePort());

result is null when being printed.

Read more here: Source link