use strict;
my $str = 'Regex: ^public ((?!({))(?!=).)*;
//MATCHES CORRECTLY
public string Country;
public string EmailAddress;
public string FirstName;
public string LastName;
public string PhoneNumber;
public string PostalCode;
public string State;
public List<Object> Example;
//MATCHES BUT SHOULDNT
public event GetUserListCompletedEventHandler GetUserListCompleted;
public delegate void GetUserListCompletedEventHandler(object sender, GetUserListCompletedEventArgs e);
//DOES NOT MATCH CORRECTLY
throw new Exception("In order to get the public date for blah blah blah");
public List<Order> orderDetails = new List<Order>();
public string CustomerName { get; set; }
public string BillingAddress1 { get; set; }
public string BillingAddress2 { get; set; }';
my $regex = qr/^(public (?:(?!{|event|delegate)[^=;])*);/mp;
my $subst = '$1 { get; set; }';
my $result = $str =~ s/$regex/$subst/rg;
print "The result of the substitution is' $result\n";
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 Perl, please visit: http://perldoc.perl.org/perlre.html