Dice Roll Parser
Instructions
Input a dice roll expression to parse. Dice rolls may be expressed as:
- A DC to match with a D20: DC12
- A check modifier to add a D20 to: +12/-12
- A complex combination of dice: 2d6+3d4-12
Sub-expressions may be placed in parenthesies: (2d6-3d4)+3d6.
You may nest sub-expressions. The number of dice (the sequence of digits
after the (e.g. 3dF).
Bugs
-
Multiple subexpressions on the same level
(e.g. (2d6-4d4)+3d20+(6d10+12)) do not work.
-
Using a subexpression as the number of dice in a dice expression
(e.g. (1d20-3)dF does not handle subexpression results
of less than 1 very well.
Credits
Original regexes and general idea taken from
GMWiki
by Devon Jones.