#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)^(public (?:(?!{|event|delegate)[^=;])*);"
Local $sString = "Regex: ^public ((?!({))(?!=).)*;" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
" //MATCHES CORRECTLY" & @CRLF & _
"public string Country;" & @CRLF & _
"public string EmailAddress;" & @CRLF & _
"public string FirstName;" & @CRLF & _
"public string LastName;" & @CRLF & _
"public string PhoneNumber;" & @CRLF & _
"public string PostalCode;" & @CRLF & _
"public string State;" & @CRLF & _
"public List<Object> Example;" & @CRLF & _
"" & @CRLF & _
" //MATCHES BUT SHOULDNT" & @CRLF & _
"public event GetUserListCompletedEventHandler GetUserListCompleted;" & @CRLF & _
"public delegate void GetUserListCompletedEventHandler(object sender, GetUserListCompletedEventArgs e);" & @CRLF & _
"" & @CRLF & _
" //DOES NOT MATCH CORRECTLY" & @CRLF & _
"throw new Exception("In order to get the public date for blah blah blah");" & @CRLF & _
"public List<Order> orderDetails = new List<Order>(); " & @CRLF & _
"public string CustomerName { get; set; }" & @CRLF & _
"public string BillingAddress1 { get; set; }" & @CRLF & _
"public string BillingAddress2 { get; set; }"
Local $sSubst = "$1 { get; set; }"
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