Automatic punctuation in lines of a MultiLine TextBox

1

I need help, so I have to write the data from a MultiLine TextBox to a Database, which is already working, but I have to do an automatic punctuation in that information that was entered by the user, I'll give you 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 above phrases will have to contain a ";", it has to be done automatically, in case the user forgets, since this information will later be exported to a Word document and must contain this punctuation.

How do I get the program to do this automatically?

    
asked by anonymous 20.06.2017 / 23:19

3 answers

0

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")+"."

Output:

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

See working at .NetFiddle

    
21.06.2017 / 01:56
0

If it is at runtime, you will have to search for javascript, there I can not help you much, but if it is only in insert time, you can execute the replace command by changing the line break.

Ex: If the content is in HTML:

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

If the text is 'normal' within the string:

texto.Replace("\r",";\r");
    
21.06.2017 / 00:10
0

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

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

And for the "." I would do:

Texto.replace(".", "");
Texto.Insert(Texto.Length, ".")
    
22.06.2017 / 16:37