#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)^Hi.*Page (\d+).*\n(.*)"
Local $sString = "Notes and highlights for" & @CRLF & _
"Outlive" & @CRLF & _
"Attia MD, Peter" & @CRLF & _
"Part I" & @CRLF & _
"Highlight (yellow) - Chapter 1: The Long Game: From Fast Death to Slow Death > Page 10 · Location 150" & @CRLF & _
"In 1900 , life expectancy hovered somewhere south of age fifty , and most people were likely to die from “ fast ” causes : accidents , injuries , and infectious diseases of various kinds . Since then , slow death has supplanted fast death . The majority of people reading this book can expect to die somewhere in their seventies or eighties , give or take , and almost all from “ slow ” causes ." & @CRLF & _
"Highlight (yellow) - Chapter 1: The Long Game: From Fast Death to Slow Death > Page 10 · Location 154" & @CRLF & _
"Four Horsemen : heart disease , cancer , neurodegenerative disease , or type 2 diabetes and related metabolic dysfunction ." & @CRLF & _
"Highlight (yellow) - Chapter 1: The Long Game: From Fast Death to Slow Death > Page 10 · Location 155" & @CRLF & _
"we must understand and confront these causes of slow death ." & @CRLF & _
"Highlight (yellow) - Chapter 1: The Long Game: From Fast Death to Slow Death > Page 10 · Location 158" & @CRLF & _
"Healthspan is typically defined as the period of life when we are free from disability or disease ," & @CRLF & _
"Highlight (yellow) - Chapter 1: The Long Game: From Fast Death to Slow Death > Page 14 · Location 215" & @CRLF & _
"It is absurd and harmful to treat this disease like a cold or a broken bone , where you either have it or you don’t ; it’s not binary ." & @CRLF & _
"Highlight (yellow) - Chapter 1: The Long Game: From Fast Death to Slow Death > Page 14 · Location 218" & @CRLF & _
"Changing that mindset must be our first step in attacking slow death . We want to delay or prevent these conditions so that we can live longer without disease , rather than lingering with disease ." & @CRLF & _
"Highlight (yellow) - Chapter 1: The Long Game: From Fast Death to Slow Death > Page 17 · Location 270" & @CRLF & _
"Exercise is by far the most potent longevity “ drug . ” No other intervention does nearly as much to prolong our lifespan and preserve our cognitive and physical function ."
Local $sSubst = "> $2 [@attia:2023 p.$1]\n"
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