Performing a procedure for each form edit I am a bit new to programming. I have some edits on my form, and for each edit completed it will have to do a procedure.

Currently, I use this code that works perfectly, but I am looking for a better way to accomplish this task. If I add another edit not have to repeat all the code.

string rgxExpr = @"(\w+)\s([\w\s]*)"; // Pega primeiro nome
string rgxExpr2 = @"\b(\w{1})"; // Abreviação
string s1, s2, s3, s4,s5;

/* EDIT 1 */
Match match1 = Regex.Match(edtAutor1.Text, rgxExpr);
Match match2 = Regex.Match(match1.Groups[1].ToString(), rgxExpr2);
s1 = match1.Groups[2].ToString().ToUpper() + ", " + match2.Groups[1].ToString().ToUpper();
// Apenas um autor
s4 = match1.Groups[2].ToString().ToUpper() + ", " + match1.Groups[1].ToString().ToUpper();
/* EDIT 2 */
Match match11 = Regex.Match(edtAutor2.Text, rgxExpr);
Match match22 = Regex.Match(match11.Groups[1].ToString(), rgxExpr2);
s2 = match11.Groups[2].ToString().ToUpper() + ", " + match22.Groups[1].ToString().ToUpper();
/* EDIT 3 */
Match match111 = Regex.Match(edtAutor3.Text, rgxExpr);
Match match222 = Regex.Match(match111.Groups[1].ToString(), rgxExpr2);
s3 = match111.Groups[2].ToString().ToUpper() + ", " + match222.Groups[1].ToString().ToUpper();
/* EDIT 4 */
Match match1111 = Regex.Match(edtAutor4.Text, rgxExpr);
Match match2222 = Regex.Match(match1111.Groups[1].ToString(), rgxExpr2);
s5 = match1111.Groups[2].ToString().ToUpper() + ", " + match2222.Groups[1].ToString().ToUpper();

if (radioButton1.Checked == true)
{
    if (edtAutor1.Text != "")
    {
        /* Bibliográfia - 1 AUTOR */
        if (string.IsNullOrWhiteSpace(edtAutor2.Text) &amp;&amp; string.IsNullOrWhiteSpace(edtAutor3.Text))
        {
            addbb.dataGridView1.Rows.Add(s4+". ", abntrTitulo.Text+"." , abntrEdicao.Text +" Ed. ", abntrLocal.Text + ": ", abntrEditor.Text + ", ",
            abntrAno.Text + ". ", abntrPaginas.Text +"p.");
        }

        /* Bibliográfia - 2 AUTORES */
        if (string.IsNullOrWhiteSpace(edtAutor3.Text))
        {
            if (edtAutor2.Text != "")
            {
                addbb.dataGridView1.Rows.Add(s1 + "; " + s2 + ". ", abntrTitulo.Text + ".", abntrEdicao.Text + " Ed. ", abntrLocal.Text + ": ", abntrEditor.Text + ", ",
            abntrAno.Text + ". ", abntrPaginas.Text + "p.");
            }
        }

        /* Bibliográfia - 3 AUTORES */
        if (string.IsNullOrWhiteSpace(edtAutor4.Text))
        {
            if (edtAutor1.Text != "" &amp; edtAutor2.Text != "" &amp; edtAutor3.Text != "")
            {
                addbb.dataGridView1.Rows.Add(s1 + "; " + s2 + "; " + s3 + ". ", abntrTitulo.Text + ".", abntrEdicao.Text + " Ed. ", abntrLocal.Text + ": ", abntrEditor.Text + ", ",
            abntrAno.Text + ". ", abntrPaginas.Text + "p.");
            }
        }

        /* Bibliográfia - 4 AUTORES */
        if (edtAutor1.Text != "" &amp; edtAutor2.Text != "" &amp; edtAutor3.Text != "" &amp; edtAutor4.Text != "")
        {
            addbb.dataGridView1.Rows.Add(s1 + "; " + s2 + "; " + s3 + ";" + s5 + ". ", abntrTitulo.Text + ".", abntrEdicao.Text + " Ed. ", abntrLocal.Text + ": ", abntrEditor.Text + ", ",
            abntrAno.Text + ". ", abntrPaginas.Text + "p.");
        }
    }
    else
    {
        MessageBox.Show("Você precisa preencher todos os campos obrigátorios (*). Por favor, verifique se todos os campos estão preenchidos corretamente!");
    }


}


The code uses regex and separates the words of EDIT, reverses the order and abbreviates.
It looks to me that you could use a method that returns the appropriate string.  Something like the following, which follows the pattern in your code:

static string GetEdit(string txt)
{
    string rgxExpr = @"(\w+)\s([\w\s]*)"; // Pega primeiro nome
    string rgxExpr2 = @"\b(\w{1})"; // Abreviação    
    Match match1 = Regex.Match(txt, rgxExpr);
    Match match2 = Regex.Match(match1.Groups[1].ToString(), rgxExpr2);
    return match1.Groups[2].ToString().ToUpper() + ", " + match2.Groups[1].ToString().ToUpper();
}


You could do something similar with the other duplicated code by using a list of strings that correspond to a list of textboxes. allowing you to add or delete as needed.