#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(<dependency>)((?!<dependency>)\s*?\S*?\w*?\W*?.*?\X*?\R*?\v*?)(spring-core)(\s*?\S*?\w*?\W*?.*?\X*?\R*?\v*?(?<!<dependency>))(<\/dependency>)"
Local $sString = "<dependency>" & @CRLF & _
" <groupId>org.springframework</groupId>" & @CRLF & _
" <artifactId>spring-jdbc</artifactId>" & @CRLF & _
" <version>${spring.version}</version>" & @CRLF & _
"</dependency>" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"<dependency>" & @CRLF & _
" <groupId>org.springframework</groupId>" & @CRLF & _
" <artifactId>spring-core</artifactId>" & @CRLF & _
" <version>${spring.version}</version>" & @CRLF & _
" <exclusions>" & @CRLF & _
" <exclusion>" & @CRLF & _
" <groupId>commons-logging</groupId>" & @CRLF & _
" <artifactId>commons-logging</artifactId>" & @CRLF & _
" </exclusion>" & @CRLF & _
" </exclusions>" & @CRLF & _
"</dependency>"
Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYFULLMATCH)
; 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