#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)^(?<block>(?:[a-z][a-z0-9]*)(?:-[a-z0-9]+)*)(?<element>(?:__[a-z][a-z0-9]*(?:-[a-z0-9]+)*))?(?<modifier>(?:--[a-z][a-z0-9]*)(?:-[a-z0-9]+)*)?$"
Local $sString = "something-something-something" & @CRLF & _
"some-class" & @CRLF & _
"some-400" & @CRLF & _
"some--class\\" & @CRLF & _
"1something" & @CRLF & _
"anything-else__and--other-things" & @CRLF & _
"anything-else__and-and--other-things" & @CRLF & _
"block" & @CRLF & _
"block__element" & @CRLF & _
"block__1element" & @CRLF & _
"block__element500" & @CRLF & _
"block__element--modifier" & @CRLF & _
"long-block__long-element--long-modifier" & @CRLF & _
"long-123__long-123--long-123" & @CRLF & _
"blocky-mc-block-face" & @CRLF & _
"block__element__element" & @CRLF & _
"block__element--modifier--modifier" & @CRLF & _
"block--modifier--modifier" & @CRLF & _
"block--modifier__element" & @CRLF & _
"block--modifier-500" & @CRLF & _
"block--1modifier" & @CRLF & _
"" & @CRLF & _
"^([a-z][a-z0-9]*)(-[a-z0-9]+)*"
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