Regular Expressions 101

Community Patterns

SparkplugB Topic Pattern

0

Regular Expression
Python

r"
^# define which type of Sparkplug this is (?P<raw> (?P<namespace> sp (?P<payload_type>[AB]) v(?P<version>[0-9.]+)) / (?P<group_id>.+?) # Commands are for either Nodes, Devices, or State (meta) / (?P<command>([ND](BIRTH|DEATH|DATA|CMD)|STATE)) / (?P<node_id>.+?) # Device ID is optional (/ (?P<topic> (?P<device_id>.+?) # there can be more to the topic, though there shouldn't be (/ (?P<remaining_topic>.+))? ))?)$
"
gmx

Description

SparkplugB has a specific pattern to the MQTT topic string. Included here is the convention of metrics as a continuation of the topic string (although as an element in the binary payload it is not!)

Submitted by null-directory - a year ago