RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Multisided dice
Expression
([1-9]{1,2})?(d|D)([1-9]{1,3})((\+|-)([1-9]{1,3}))?
Description
For the geeks out there, you can use this to break down die rolls of multisided dice for things like role playing games. Includes support for a die multiplier and an end modifier value. Supports a multiplier up to 99, and sides and a modifier of up to 999.
Matches
d12 | 2d4 | 3D8-2 | 99D999+999
Non-Matches
0d6 | 100d4 | 2a4 | 3D8*3
Author Rating: The rating for this expression. Michael Fienen
Source
Your Rating
Bad Good

Enter New Comment

Title
 
Name
 
Comment
 
Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Title: Modified Version
Name: formlesstree4
Date: 2/8/2015 11:19:46 PM
Comment:
Brandon. Try this: ([1-9]{1,2})?(d|D)([1-9]{1,1}([0-9]{1,2})?)((\+|-)([1-9]{1,3}))?


Title: Modifier only works if single digit
Name: Branden
Date: 2/4/2015 9:22:11 PM
Comment:
Your regex LOOKS like it should work, but the RegEx testers I ran it against only capture the first digit of the modifier. For example, with "2D6+100", only "2D6+1" is matched. I'm puzzled as to why it doesn't work, however. I tested it here: http://www.freeformatter.com/regex-tester.html And here: http://myregexp.com/


Copyright © 2001-2018, RegexAdvice.com | ASP.NET Tutorials