Skip to content

Instantly share code, notes, and snippets.

@conanak99
Created February 12, 2020 08:42
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 conanak99/e50b489cae7660a3436448c5e17d3d8a to your computer and use it in GitHub Desktop.
Save conanak99/e50b489cae7660a3436448c5e17d3d8a to your computer and use it in GitHub Desktop.
getBetFromComment(comment) {
const cleanedComment = textParser.charToNumber(
textParser.removeUnicode(comment.toLowerCase()));
const regex = /(\d+)( |-)?(cop|bau|ga|tom|ca|cua)/;
const matches = cleanedComment.match(regex);
if (!matches) return [];
const bets = matches.map(match => {
const execMatch = regex.exec(match);
const bet = parseInt(execMatch[1], 10);
const choice = choiceToNumberMap[execMatch[3]];
return { bet, choice };
});
return bets;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment