#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)modelBuilder\.Entity<(?'type'\w+)>\(builder =>\n\s*\{(?'builder'[\w\W]+?)\}\);"
Local $sString = "modelBuilder.Entity<Foobar>(builder =>" & @CRLF & _
" {" & @CRLF & _
" builder.HasKey(e => e.Id).HasName("PRIMARY");" & @CRLF & _
"" & @CRLF & _
" builder" & @CRLF & _
" .ToTable("foobar")" & @CRLF & _
" .UseCollation("utf8mb4_0900_ai_ci");" & @CRLF & _
"" & @CRLF & _
" builder.HasIndex(e => e.A, "A").IsUnique();" & @CRLF & _
"" & @CRLF & _
" builder.Property(e => e.D).HasColumnType("datetime");" & @CRLF & _
" builder.Property(e => e.E)" & @CRLF & _
" .HasMaxLength(255)" & @CRLF & _
" .UseCollation("utf8mb4_unicode_ci");" & @CRLF & _
" builder.Property(e => e.N)" & @CRLF & _
" .HasMaxLength(255)" & @CRLF & _
" .UseCollation("utf8mb4_unicode_ci");" & @CRLF & _
"" & @CRLF & _
" builder.HasOne(d => d.ANav).WithOne(p => p.BNav)" & @CRLF & _
" .HasForeignKey<Foobar>(d => d.Leerling)" & @CRLF & _
" .HasConstraintName("Foobar_fk");" & @CRLF & _
" });"
Local $sSubst = "public class $1Mapping : IEntityTypeConfiguration<$1>\n{\n public void Configure(EntityTypeBuilder<$1> builder)\n {\n$2\n}}"
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