#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?s)^.*?\"longitude[^\[]*?\"activity[^\[]*\[[^\]]*?timestampMs\"[^\"\]]*\"(\d+)\"[^\]]*WALKING[^\]]*?confidence\"\s*:\s*(\b\d{1,3}\b)[^\]]*?\].*$"
Local $sString = " }, {" & @CRLF & _
" "timestampMs" : "1515564666086", ◁― Don't need this but it won't hurt" & @CRLF & _
" "latitudeE7" : -6857630899, " & @CRLF & _
" "longitudeE7" : -1779694452999," & @CRLF & _
" "activity" : [ {" & @CRLF & _
" "timestampMs" : "1515564665992", ◁― EXAMPLE: I want only this, and..." & @CRLF & _
" "activity" : [ {" & @CRLF & _
" "type" : "STILL"," & @CRLF & _
" "confidence" : 65" & @CRLF & _
" }, {" & @CRLF & _
" "type" : "TILTING", ↓" & @CRLF & _
" "confidence" : 4" & @CRLF & _
" }, {" & @CRLF & _
" "type" : "IN_RAIL_VEHICLE"," & @CRLF & _
" "confidence" : 20" & @CRLF & _
" }, {" & @CRLF & _
" "type" : "IN_ROAD_VEHICLE"," & @CRLF & _
" "confidence" : 5" & @CRLF & _
" }, {" & @CRLF & _
" "type" : "ON_FOOT", ↓" & @CRLF & _
" "confidence" : 3" & @CRLF & _
" }, {" & @CRLF & _
" "type" : "UNKNOWN"," & @CRLF & _
" "confidence" : 3" & @CRLF & _
" }, {" & @CRLF & _
" "type" : "WALKING", ◁― ...AND, I also want this." & @CRLF & _
" "confidence" : 3" & @CRLF & _
" } ]" & @CRLF & _
" } ]" & @CRLF & _
" }, {" & @CRLF & _
" "timestampMs" : "1515564662594", ◁― Don't need this but it won't hurt" & @CRLF & _
" "latitudeE7" : -6857630899, " & @CRLF & _
" "longitudeE7" : -1779694452999," & @CRLF & _
" "altitude" : 42" & @CRLF & _
" }, {"
Local $sSubst = "\1 \2"
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