0

create a project that will allow the user to enter a mailing address. The address may not contain any leading or trailing spacebars and may not contain the following special characters. • Period key (.) • Comma (,) • Semicolon (;) The user will enter a mailing address into a Text Box. When the appropriate button is selected, the entered address will be checked for any invalid characters. The resulting/corrected address will then be displayed into a Label.

I have written code but I cannot figure out how to display it in the label box without the period, comma, and semicolon

        string wordString;
        char[] delimChar = { ',', '.', ';' };

        wordString = entryTextBox.Text;
        wordString = wordString.Trim();
        string[] delimString = wordString.Split(delimChar);

I have no error messages in the code but need some additional help.

Devin128
  • 5
  • 5
  • Duplicate explains exactly what you try to do. Problem in code you wrote is duplicate of https://stackoverflow.com/questions/15659409/how-do-you-display-a-string-array-in-a-text-box – Alexei Levenkov Oct 01 '19 at 03:40

1 Answers1

1

You could just use regex replace

var input = "    P.O, Box123;";
var pattern = @"^ *|\.|,|;";

var result = Regex.Replace(input, pattern, "");

Console.WriteLine(result);

Output

PO Box123

Demo Here

TheGeneral
  • 79,002
  • 9
  • 103
  • 141