Test, validate and match regular expressions
This regex matches dice roll notation in tabletop RPGs and games, capturing the number of dice, die size, and an optional modifier (addition or subtraction). It supports various formats like '2d6+3', '1D20', '3w8-1', accepting both lowercase and uppercase 'd' or 'w' as the separator. The named capture groups (num_dice, die_size, modifier) make it easy to extract each component of a roll expression for further processing in dice rolling applications or game mechanics.