#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "^(\s+)<ProjectReference(.|\s)+?(Project2)</Name>(.|\s)+?</ProjectReference>"
Local $sString = " <ProjectReference Include="..\..\Project1\Project1\Project1.csproj">" & @CRLF & _
" <Project>{714c6b26-c609-40a4-80a9-421bd842562d}</Project>" & @CRLF & _
" <Name>Project1</Name>" & @CRLF & _
" </ProjectReference>" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
" <ItemGroup>" & @CRLF & _
" <ProjectReference Include="..\..\Project2\Project2.csproj">" & @CRLF & _
" <Project>{6c2a7631-8b47-4ae9-a68f-f728666105b9}</Project>" & @CRLF & _
" <Name>Project2</Name>" & @CRLF & _
" </ProjectReference>" & @CRLF & _
" <ProjectReference Include="..\..\Project3\Project3\Project3.csproj">" & @CRLF & _
" <Project>{39860208-8146-429f-a1d1-5f8ed2fd7f5f}</Project>" & @CRLF & _
" <Name>Project3</Name>" & @CRLF & _
" </ProjectReference>" & @CRLF & _
" <ProjectReference Include="..\..\Project4\Project4.csproj">" & @CRLF & _
" <Project>{58144d60-19d9-4d11-8ae6-088e03ccf874}</Project>" & @CRLF & _
" <Name>Project4</Name>" & @CRLF & _
" </ProjectReference>" & @CRLF & _
" <ProjectReference Include="..\..\Project5\Project5.csproj">" & @CRLF & _
" <Project>{33baa509-ad24-4a72-a2fc-8f297e75e90d}</Project>" & @CRLF & _
" <Name>Project5</Name>" & @CRLF & _
" </ProjectReference>" & @CRLF & _
" </ItemGroup>" & @CRLF & _
" <PropertyGroup>" & @CRLF & _
" <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>" & @CRLF & _
" <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>" & @CRLF & _
" </PropertyGroup>"
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