#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)^(?<![\s\S\r])(.*)"
Local $sString = "# project1" & @CRLF & _
"I could have put any other inline tag or string there." & @CRLF & _
"This main body line could have been the very first line as well, if no tags exist." & @CRLF & _
"" & @CRLF & _
"Change the keys after each `\n` and add or remove any more keys you want." & @CRLF & _
"In this example, I added the desired tag in the indented multi-line format favoured by Obsidian." & @CRLF & _
"If it is a first time doing regex changes, make a backup of vault or Diary folder."
Local $sSubst = "---\ntags: \n - m/diary\n---\n\n$1"
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