#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "export\s+async\s+function\s+generateMetadata\s*\(\s*\{[\s\S]*?\}\s*\):\s*Promise<Metadata>\s*{\s*const\s*\{\s*t\s*\}\s*=\s*await\s*translationServer\s*\(\s*locale\s*,\s*'projectTitles'\s*\);\s*return\s*\{\s*title\s*:\s*translate\s*\}?\s*}"
Local $sString = "import { Metadata } from 'next';" & @CRLF & _
"" & @CRLF & _
"import CreateEnactment from './_components';" & @CRLF & _
"import { translationServer } from 'i18n';" & @CRLF & _
"import { hasPermissionServerSide } from 'utils';" & @CRLF & _
"" & @CRLF & _
"const CreateEnactmentPage = async () => {" & @CRLF & _
" await hasPermissionServerSide({ branchRoles: ['ADMIN', 'OPERATOR'] });" & @CRLF & _
"" & @CRLF & _
" return <CreateEnactment />;" & @CRLF & _
"};" & @CRLF & _
"" & @CRLF & _
"export async function generateMetadata({ params: { locale, enactmentId } }: { params: Params }): Promise<Metadata> {" & @CRLF & _
" const { t } = await translationServer(locale, 'projectTitles');" & @CRLF & _
"" & @CRLF & _
" const translate = enactmentId === 'new-enactment' ? t('newEnactment') : t('viewEnactment');" & @CRLF & _
"" & @CRLF & _
" // to meta tag" & @CRLF & _
" return {" & @CRLF & _
" title: translate" & @CRLF & _
" };" & @CRLF & _
"}" & @CRLF & _
"" & @CRLF & _
"export default CreateEnactmentPage;" & @CRLF & _
""
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