Skip to content

Instantly share code, notes, and snippets.

@nberlette
Created May 3, 2021 04:25
Show Gist options
  • Save nberlette/3109a3f034ad743aa9af957ae5e73bea to your computer and use it in GitHub Desktop.
Save nberlette/3109a3f034ad743aa9af957ae5e73bea to your computer and use it in GitHub Desktop.
DBC Regular Expressions
/* dbc-patterns.js */
const VER_REGEX = /^VERSION "(.*)"/
const ECU_REGEX = /^BU_:(.*)/
const MSG_REGEX = /^BO_ (\w+) (\w+) *: (\w+) (\w+)/
const SIG_REGEX = /^SG_ (\w+) : (\d+)\|(\d+)@(\d+)([+|-]) \(([0-9.+-eE]+),([0-9.+-eE]+)\) \[([0-9.+-eE]+)\|([0-9.+-eE]+)\] "(.*)" (.*)/
const SGM_REGEX = /^SG_ (\w+) (\w+) *: (\d+)\|(\d+)@(\d+)([+|-]) \(([0-9.+-eE]+),([0-9.+-eE]+)\) \[([0-9.+-eE]+)\|([0-9.+-eE]+)\] "(.*)" (.*)/
const VAL_REGEX = /^VAL_ (\w+) (\w+) (.*);?/
const VAL_TABLE_REGEX = /^VAL_TABLE_ (\w+) (.*);?/
const MSG_TX_REGEX = /^BO_TX_BU_ ([0-9]+) *: *(.+);?/
const DBC_COMMENT_REGEX = /^CM_ *"(.*)";?/
const SIG_COMMENT_REGEX = /^CM_ SG_ *(\w+) *(\w+) *"(.*)";?/
const MSG_COMMENT_REGEX = /^CM_ BO_ *(\w+) *"(.*)";?/
const ECU_COMMENT_REGEX = /^CM_ BU_ *(\w+) *"(.*)";?/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment