Skip to content

Instantly share code, notes, and snippets.

@conanak99
Created Feb 12, 2020
Embed
What would you like to do?
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