Regular Expressions 101

Community Patterns

Dice roll notation

0

Regular Expression
ECMAScript (JavaScript)

/
(?<operator>[+\-])?(?:(?<dice>(?<numberOfDice>[\d]+)?[dD](?<faces>[\d]+)(?<explode>![\d]*)?(?<implode>¡[\d]*)?(?<selective>[kd][\d]+)?)|(?<constant>[\d]+))
/
gm

Description

Map operator, constants, number of dice, number of faces, exploding/imploding and selective dice notations

Submitted by anonymous - 4 years ago