node-serialport-bindings-cpp/docs/api-parser-regex.md
Francis Gulotta 4318c25383
docs: New docs system (#1647)
- remove old docs
- docusaurus docs
- guides
- api docs
- basic homepage
2018-09-09 05:12:19 -04:00

736 B

id title
api-parser-regex Regex Parser
new Regex(options)

A transform stream that uses a regular expression to split the incoming text upon.

To use the Regex parser provide a regular expression to split the incoming text upon. Data is emitted as string controllable by the encoding option (defaults to utf8).

Arguments

  • options.regex: RegExp the regular expression to use to split incoming text
  • options.encoding?: string text encoding for the stream
const SerialPort = require('serialport')
const Regex = require('@serialport/parser-regex')
const port = new SerialPort('/dev/tty-usbserial1')

const parser = port.pipe(new Regex({ regex: /[\r\n]+/ }))
parser.on('data', console.log)