#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)^(?<numberExpression>(?<numberDice>[0-9]+)(?<gaussExpression>[oO]?(?<gaussDices>[0-9])+(?<gaussModifier>[\+\-])?)?)?[dD](?<faces>[0-9]+)(?<exploding>[¡!]{0,2})(?<modifierExpression>[\+\-](?<modifierValue>[0-9]+))?(?<thresholdExp>:(?<thresholdValue>[0-9]+))?"
Local $sString = "Common dice:" & @CRLF & _
"1d2 (coin flip)" & @CRLF & _
"2d4" & @CRLF & _
"3d6" & @CRLF & _
"4d8" & @CRLF & _
"5d10" & @CRLF & _
"6d12" & @CRLF & _
"7d20" & @CRLF & _
"8d30" & @CRLF & _
"9d100" & @CRLF & _
"" & @CRLF & _
"Gauss notation:" & @CRLF & _
"1o3d10 Basic notation" & @CRLF & _
"1o3+d10 Gauss with gauss-modifier" & @CRLF & _
"1o3-d10 Gauss with gauss-modifier" & @CRLF & _
"1o5d8 Gauss with other configurations" & @CRLF & _
"" & @CRLF & _
"Exploding dice:" & @CRLF & _
"1d10! Exploding" & @CRLF & _
"1d10¡ Imploding" & @CRLF & _
"1d10!¡ Both, exploding and imploding" & @CRLF & _
"1d10¡! Another possible arrangement" & @CRLF & _
"1o3d10! Gauss exploding" & @CRLF & _
"" & @CRLF & _
"Adding and substracting:" & @CRLF & _
"1d10+20" & @CRLF & _
"1d10-3 " & @CRLF & _
"1o3d10+3 Gauss with modifiers" & @CRLF & _
"1o3d10!-3 Gauss with exploding dice and modifiers" & @CRLF & _
"" & @CRLF & _
"Threshold:" & @CRLF & _
"1d10:6" & @CRLF & _
"1d10+2:8 Modifier and threshold" & @CRLF & _
"1d10!+1:8 Exploding, modifier and threshold" & @CRLF & _
"1o3+d10!+3:8 Gauss with gauss-modifier, exploding option, modifier and threshold"
Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYGLOBALFULLMATCH)
Local $aFullArray[0]
For $i = 0 To UBound($aArray) -1
_ArrayConcatenate($aFullArray, $aArray[$i])
Next
$aArray = $aFullArray
; Present the entire match result
_ArrayDisplay($aArray, "Result")
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for AutoIt, please visit: https://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm