#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)(?x) # free-spacing mode" & @CRLF & _
"(?(DEFINE)" & @CRLF & _
" # Within this DEFINE block, we'll define many subroutines" & @CRLF & _
" # They build on each other like lego until we can define" & @CRLF & _
" # a "big number"" & @CRLF & _
"" & @CRLF & _
" (?<one_to_9> " & @CRLF & _
" # The basic regex:" & @CRLF & _
" # one|two|three|four|five|six|seven|eight|nine" & @CRLF & _
" # We'll use an optimized version:" & @CRLF & _
" # Option 1: four|eight|(?:fiv|(?:ni|o)n)e|t(?:wo|hree)|" & @CRLF & _
" # s(?:ix|even)" & @CRLF & _
" # Option 2:" & @CRLF & _
" (?:f(?:ive|our)|s(?:even|ix)|t(?:hree|wo)|(?:ni|o)ne|eight)" & @CRLF & _
" ) # end one_to_9 definition" & @CRLF & _
"" & @CRLF & _
" (?<ten_to_19> " & @CRLF & _
" # The basic regex:" & @CRLF & _
" # ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|" & @CRLF & _
" # eighteen|nineteen" & @CRLF & _
" # We'll use an optimized version:" & @CRLF & _
" # Option 1: twelve|(?:(?:elev|t)e|(?:fif|eigh|nine|(?:thi|fou)r|" & @CRLF & _
" # s(?:ix|even))tee)n" & @CRLF & _
" # Option 2:" & @CRLF & _
" (?:(?:(?:s(?:even|ix)|f(?:our|if)|nine)te|e(?:ighte|lev))en|" & @CRLF & _
" t(?:(?:hirte)?en|welve)) " & @CRLF & _
" ) # end ten_to_19 definition" & @CRLF & _
"" & @CRLF & _
" (?<two_digit_prefix>" & @CRLF & _
" # The basic regex:" & @CRLF & _
" # twenty|thirty|forty|fifty|sixty|seventy|eighty|ninety" & @CRLF & _
" # We'll use an optimized version:" & @CRLF & _
" # Option 1: (?:fif|six|eigh|nine|(?:tw|sev)en|(?:thi|fo)r)ty" & @CRLF & _
" # Option 2:" & @CRLF & _
" (?:s(?:even|ix)|t(?:hir|wen)|f(?:if|or)|eigh|nine)ty" & @CRLF & _
" ) # end two_digit_prefix definition" & @CRLF & _
"" & @CRLF & _
" (?<one_to_99>" & @CRLF & _
" (?&two_digit_prefix)(?:[- ](?&one_to_9))?|(?&ten_to_19)|" & @CRLF & _
" (?&one_to_9)" & @CRLF & _
" ) # end one_to_99 definition" & @CRLF & _
"" & @CRLF & _
" (?<one_to_999>" & @CRLF & _
" (?&one_to_9)[ ]hundred(?:[ ](?:and[ ])?(?&one_to_99))?|" & @CRLF & _
" (?&one_to_99)" & @CRLF & _
" ) # end one_to_999 definition" & @CRLF & _
"" & @CRLF & _
" (?<one_to_999_999>" & @CRLF & _
" (?&one_to_999)[ ]thousand(?:[ ](?&one_to_999))?|" & @CRLF & _
" (?&one_to_999)" & @CRLF & _
" ) # end one_to_999_999 definition" & @CRLF & _
"" & @CRLF & _
" (?<one_to_999_999_999>" & @CRLF & _
" (?&one_to_999)[ ]million(?:[ ](?&one_to_999_999))?|" & @CRLF & _
" (?&one_to_999_999)" & @CRLF & _
" ) # end one_to_999_999_999 definition" & @CRLF & _
"" & @CRLF & _
" (?<one_to_999_999_999_999>" & @CRLF & _
" (?&one_to_999)[ ]billion(?:[ ](?&one_to_999_999_999))?|" & @CRLF & _
" (?&one_to_999_999_999)" & @CRLF & _
" ) # end one_to_999_999_999_999 definition" & @CRLF & _
"" & @CRLF & _
" (?<one_to_999_999_999_999_999>" & @CRLF & _
" (?&one_to_999)[ ]trillion(?:[ ](?&one_to_999_999_999_999))?|" & @CRLF & _
" (?&one_to_999_999_999_999)" & @CRLF & _
" ) # end one_to_999_999_999_999_999 definition" & @CRLF & _
" # ==== MORE ====" & @CRLF & _
" (?<one_to_quadrillion>" & @CRLF & _
" (?&one_to_999)[ ]quadrillion(?:[ ](?&one_to_999_999_999_999_999))?|" & @CRLF & _
" (?&one_to_999_999_999_999_999)" & @CRLF & _
" ) # end one_to_quadrillion definition" & @CRLF & _
" (?<one_to_quintillion>" & @CRLF & _
" (?&one_to_999)[ ]quintillion(?:[ ](?&one_to_quadrillion))?|" & @CRLF & _
" (?&one_to_quadrillion)" & @CRLF & _
" ) # end one_to_quintillion definition" & @CRLF & _
" (?<one_to_sextillion>" & @CRLF & _
" (?&one_to_999)[ ]sextillion(?:[ ](?&one_to_quintillion))?|" & @CRLF & _
" (?&one_to_quintillion)" & @CRLF & _
" ) # end one_to_sextillion definition" & @CRLF & _
" (?<one_to_septillion>" & @CRLF & _
" (?&one_to_999)[ ]septillion(?:[ ](?&one_to_sextillion))?|" & @CRLF & _
" (?&one_to_sextillion)" & @CRLF & _
" ) # end one_to_septillion definition" & @CRLF & _
" (?<one_to_octillion>" & @CRLF & _
" (?&one_to_999)[ ]octillion(?:[ ](?&one_to_septillion))?|" & @CRLF & _
" (?&one_to_septillion)" & @CRLF & _
" ) # end one_to_octillion definition" & @CRLF & _
" (?<one_to_nonillion>" & @CRLF & _
" (?&one_to_999)[ ]nonillion(?:[ ](?&one_to_octillion))?|" & @CRLF & _
" (?&one_to_octillion)" & @CRLF & _
" ) # end one_to_nonillion definition" & @CRLF & _
" (?<one_to_decillion>" & @CRLF & _
" (?&one_to_999)[ ]decillion(?:[ ](?&one_to_nonillion))?|" & @CRLF & _
" (?&one_to_nonillion)" & @CRLF & _
" ) # end one_to_decillion definition" & @CRLF & _
"" & @CRLF & _
" (?<bignumber>" & @CRLF & _
" zero|(?&one_to_decillion)" & @CRLF & _
" ) # end bignumber definition" & @CRLF & _
"" & @CRLF & _
" (?<zero_to_9>" & @CRLF & _
" (?&one_to_9)|zero" & @CRLF & _
" ) # end zero to 9 definition" & @CRLF & _
"" & @CRLF & _
" # (?<decimals>" & @CRLF & _
" # point(?:[ ](?&zero_to_9))+" & @CRLF & _
" # ) # end decimals definition" & @CRLF & _
" " & @CRLF & _
") # End DEFINE" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"####### The Regex Matching Starts Here ########" & @CRLF & _
"\b(?:(?&ten_to_19)\s+hundred|(?&bignumber))\b" & @CRLF & _
"#\b(?:(?&ten_to_19)\s+hundred|(?&bignumber)(?:[ ](?&decimals))?)\b # No decimals for now" & @CRLF & _
"" & @CRLF & _
"### Other examples of groups we could match ###" & @CRLF & _
"#(?&bignumber)" & @CRLF & _
"# (?&one_to_99)" & @CRLF & _
"# (?&one_to_999)" & @CRLF & _
"# (?&one_to_999_999)" & @CRLF & _
"# (?&one_to_999_999_999)" & @CRLF & _
"# (?&one_to_999_999_999_999)" & @CRLF & _
"# (?&one_to_999_999_999_999_999)"
Local $sString = "one" & @CRLF & _
"twelve" & @CRLF & _
"seventy two" & @CRLF & _
"three hundred" & @CRLF & _
"twelve hundred" & @CRLF & _
"twelve thousand three hundred four" & @CRLF & _
"six million" & @CRLF & _
"six million four hundred thousand five" & @CRLF & _
"one hundred twenty three billion four hundred fifty six million seven hundred eighty nine thousand twelve" & @CRLF & _
"four decillion"
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