RegExMatch(full_command_line, " /restart(?!\S)")is doing. I tested this code and it seems we could simply remove RegExMatch part without any difference in the behaviour. But probably I miss something?
full_command_line := DllCall("GetCommandLine", "str")
if not (A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)"))
Run *RunAs "%A_ScriptFullPath%" /restart
Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
MsgBox A_IsAdmin: %A_IsAdmin%`nCommand line: %full_command_line%