Skip to content

Instantly share code, notes, and snippets.

@waptik
Last active April 2, 2021 23:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save waptik/565f9ec9bbb798c90a581b5e4b098152 to your computer and use it in GitHub Desktop.
Save waptik/565f9ec9bbb798c90a581b5e4b098152 to your computer and use it in GitHub Desktop.
regex to filter bot command and args
// ref https://flaviocopes.com/javascript-regular-expressions
const re=/(?<code>(c|g)_\w+)(.)(?<to>to)(.)(?<id>id\d+)/
console.log(re.exec("c_84www to id890890")) // returns ["c_84www to id890890", "c_84www", "c", " ", "to", " ", "id890890", index: 0, input: "c_84www to id890890", groups: {code: "c_84www", to: "to", id: "id890890"}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment