#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(<dependency>\s+<groupId>)(.+)(</groupId>\s+<artifactId>)(.+)(</artifactId>\s+<version>)([^\$]+?)(</version>[\s\S]*?\s+</dependency>)"
Local $sString = " <dependency>" & @CRLF & _
" <groupId>org.example.one</groupId>" & @CRLF & _
" <artifactId>example1</artifactId>" & @CRLF & _
" <version>1.2.3</version>" & @CRLF & _
" </dependency>" & @CRLF & _
" <dependency>" & @CRLF & _
" <groupId>org.example.two</groupId>" & @CRLF & _
" <artifactId>example2</artifactId>" & @CRLF & _
" <version>${example2.version}</version>" & @CRLF & _
" </dependency>" & @CRLF & _
" <dependency>" & @CRLF & _
" <groupId>org.example.three</groupId>" & @CRLF & _
" <artifactId>example3</artifactId>" & @CRLF & _
" <version>1.2.3</version>" & @CRLF & _
" <scope>test</scope>" & @CRLF & _
" </dependency>" & @CRLF & _
" <dependency>" & @CRLF & _
" <groupId>org.example.four</groupId>" & @CRLF & _
" <artifactId>example4</artifactId>" & @CRLF & _
" <version>${example4.version}</version>" & @CRLF & _
" <scope>test</scope>" & @CRLF & _
" </dependency>" & @CRLF & _
" <dependency>" & @CRLF & _
" <groupId>org.example.five</groupId>" & @CRLF & _
" <artifactId>example5</artifactId>" & @CRLF & _
" <version>1.2.3</version>" & @CRLF & _
" <scope>test</scope>" & @CRLF & _
" <exclusions>" & @CRLF & _
" <exclusion>" & @CRLF & _
" <artifactId>*</artifactId>" & @CRLF & _
" <groupId>*</groupId>" & @CRLF & _
" </exclusion>" & @CRLF & _
" </exclusions>" & @CRLF & _
" </dependency>" & @CRLF & _
" <dependency>" & @CRLF & _
" <groupId>org.example.six</groupId>" & @CRLF & _
" <artifactId>example6</artifactId>" & @CRLF & _
" <version>${example6.version}</version>" & @CRLF & _
" <scope>test</scope>" & @CRLF & _
" <exclusions>" & @CRLF & _
" <exclusion>" & @CRLF & _
" <artifactId>*</artifactId>" & @CRLF & _
" <groupId>*</groupId>" & @CRLF & _
" </exclusion>" & @CRLF & _
" </exclusions>" & @CRLF & _
" </dependency>"
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