mqtt-regex-builder
v1.1.0
Published
A library which formats a mqtt pattern as a regex
Downloads
2
Readme
mqtt-regex-builder
Create a suitable Regex from an Mqtt subscription topic, including captures.
Usage
var mqttRegexBuilder = require( 'mqtt-regex-builder' );
var regex = mqttRegexBuilder( 'nomalights/+/out/#' );
var match = regex.exec( 'nomalights/some-device-id/out/status/heartbeat' );
var deviceId = match[1]; // 'some-device-id'
var remainingTopic = match[2]; // 'status/heartbeat'