#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)^(?:(.+?)\.(C\d{1,2}))?(?:.*?(B\d{1,2}))?\.(?:.*?(42U|48U))?.*-(.+)$"
Local $sString = "This.is.Test.Nr.One.C01B01.42U.Rack.08-Datacenter1" & @CRLF & _
"Is.this.Nr.Two.C03B03.London.48U.Rack.04-Datacenter4" & @CRLF & _
"This.Number.Random.C02.Frankfurt.42U.Rack.12-Datacenter1" & @CRLF & _
"This.is.Random.Number.C08B01.Zuerich.Rack.01-Datacenter2" & @CRLF & _
"Is.this.Nr.Two.B03.London.48U.Rack.04-Datacenter4"
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