#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?:\[device name\]:\[?|\[name_of_device\]- |,)([^\],\r\n]*)(?=.*\r?\n(?:[ \t]*\[.*\r?\n)*?[ \t]*\[(?:current software\]: |software_running\]- )(.*))"
Local $sString = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. This is a list of all kinds of models, software, and release dates. See below for more details" & @CRLF & _
"{" & @CRLF & _
" #device batch 1 info can be found below" & @CRLF & _
" {" & @CRLF & _
" [device name]:device_1" & @CRLF & _
" [initial software]: SW$1_978qhuhk" & @CRLF & _
" [current software]: sW98203_973" & @CRLF & _
" [date] : 2022-01-05" & @CRLF & _
" }" & @CRLF & _
" {" & @CRLF & _
" [device name]:[device_2, device_3]" & @CRLF & _
" [initial software]: sW$3_jghs" & @CRLF & _
" [current software]: sW$3_jghs2" & @CRLF & _
" [date] : 2022-07-03" & @CRLF & _
" }" & @CRLF & _
"#wifi devices can be found here" & @CRLF & _
" {" & @CRLF & _
" {" & @CRLF & _
" "nested children":" & @CRLF & _
" [device name]:[w_device_1, w_device_pro]" & @CRLF & _
" [initial software]: 982637012_sw" & @CRLF & _
" [current software]: 93834932_swp$" & @CRLF & _
" [date] : 2024-02-01" & @CRLF & _
" }" & @CRLF & _
" {" & @CRLF & _
" [name_of_device]- mesh_plus" & @CRLF & _
" [installation_date]-2023-03-21" & @CRLF & _
" [software_running]- mesh_sw_old" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
""
Local $sSubst = ""
Local $sResult = StringRegExpReplace($sString, $sRegex, $sSubst)
MsgBox($MB_SYSTEMMODAL, "Result", $sResult)
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