#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?:image:\s+name:\s*|image:\s*|services:\s+-\s+|FROM\s+)(?<depName>[\S]+):(?<currentValue>[\S]+)"
Local $sString = "job2:" & @CRLF & _
" image:" & @CRLF & _
" name: docker:23.0.6-alpine3.17" & @CRLF & _
" services:" & @CRLF & _
" - docker:23.0.6-dind-alpine3.17" & @CRLF & _
" variables:" & @CRLF & _
" DOCKER_DRIVER: overlay2" & @CRLF & _
" script:" & @CRLF & _
" - echo test 2" & @CRLF & _
"" & @CRLF & _
"job3:" & @CRLF & _
" image: hadolint/hadolint:v2.12.0-alpine" & @CRLF & _
" script:" & @CRLF & _
" - echo test 3" & @CRLF & _
"" & @CRLF & _
"include:" & @CRLF & _
" - local: test.gitlab-ci.yml" & @CRLF & _
"" & @CRLF & _
"job1:" & @CRLF & _
" image: python:3.11.4-alpine3.17" & @CRLF & _
" script:" & @CRLF & _
" - echo test 1" & @CRLF & _
"" & @CRLF & _
"FROM python:3.11.4-alpine3.17" & @CRLF & _
"" & @CRLF & _
""
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