# If you'd like to omit non-matching lines from the result; add ';d' to the end of the expression.
sed -E 's/modelBuilder\.Entity<(?'type'\w+)>\(builder =>\n\s*\{(?'builder'[\w\W]+?)\}\);/public class $1Mapping : IEntityTypeConfiguration<$1>\n{\n public void Configure(EntityTypeBuilder<$1> builder)\n {\n$2\n}}/gm;t' <<< "modelBuilder.Entity<Foobar>(builder =>
{
builder.HasKey(e => e.Id).HasName(\"PRIMARY\");
builder
.ToTable(\"foobar\")
.UseCollation(\"utf8mb4_0900_ai_ci\");
builder.HasIndex(e => e.A, \"A\").IsUnique();
builder.Property(e => e.D).HasColumnType(\"datetime\");
builder.Property(e => e.E)
.HasMaxLength(255)
.UseCollation(\"utf8mb4_unicode_ci\");
builder.Property(e => e.N)
.HasMaxLength(255)
.UseCollation(\"utf8mb4_unicode_ci\");
builder.HasOne(d => d.ANav).WithOne(p => p.BNav)
.HasForeignKey<Foobar>(d => d.Leerling)
.HasConstraintName(\"Foobar_fk\");
});"
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 SED, please visit: https://www.gnu.org/software/sed/manual/html_node/The-_0022s_0022-Command.html