Automatic punctuation of lines in a multiline TextBox

I need help, that's it, I have to write the data from a multiline TextBox to a database, which is already working, but I have to make an automatic score on this information that was entered by the user, I will give an example:

        Isto é a primeira frase; 
        Isto é a segunda frase; 
        Isto é a última frase.

The last sentence will always have to contain a "."and the sentences above that will have to contain a";", it has to be done automatically, if the user forgets, because this information will be more later exported to a Word document and have to contain that score.

How do I get the program to do this automatically ?

 1
Author: Paulo Martins, 2017-06-20

3 answers

You can use regex and make a replace

string pattern = @"\s+\n";
string input = @"Isto é a primeira frase 
Isto é a segunda frase  
Isto é a última frase";
Regex.Replace(input,pattern,";\r\n")+"."

Saida:

Isto é a primeira frase;
Isto é a segunda frase;
Isto é a última frase.

See working in .NetFiddle

 0
Author: Tiago S, 2017-06-20 23:56:41

If it is at runtime, you will have to look for javascript, then I can not help you much anymore, however, if it is only at the time of insert, you can run the command replace, changing the line break characters.

Ex: if the content is in HTML:

texto.Replace("<br>",";<br>");

If the text is 'normal' inside the string:

texto.Replace("\r",";\r");
 0
Author: Rovann Linhalis, 2017-06-20 22:10:58

To ensure there will be the"; " I would do the following:

Texto.replace(";", "").replace("\n", ";\n");

And for the "."I would:

Texto.replace(".", "");
Texto.Insert(Texto.Length, ".")
 0
Author: Cassio Alves, 2017-06-22 14:37:52