feat: added support for commas and dots in the message

* message check now passes when spaces, commas and dots are used in the
message
* closes #1
This commit is contained in:
citizen-VM 2020-08-24 21:29:23 +02:00
parent 79b446494f
commit 272f3e58aa
Signed by: wanderer
GPG Key ID: 6391444A736EEE7E

View File

@ -29,7 +29,16 @@ namespace KRY_0x01_ng
public string restore_order(string str)
{
string alpha_str = Regex.Replace(str, "SPACEBRO", " ");
return alpha_str;
Regex.Replace(alpha_str, "COMMABRO", ",");
return Regex.Replace(alpha_str, "DOTBRO", ".");
}
string introduce_chaos(string str)
{
string nustr = Regex.Replace(str, " ", "SPACEBRO");
Regex.Replace(nustr, "W", "V");
Regex.Replace(nustr, ",", "COMMABRO");
return Regex.Replace(nustr, ".", "DOTBRO");
}
public string pad(string str)
@ -155,14 +164,13 @@ namespace KRY_0x01_ng
MessageBox.Show("Empty message, nothing to do.", "Warning");
return;
}
string msg = Regex.Replace(tb_m.Text.ToUpper(), " ", "SPACEBRO");
string msg = introduce_chaos(tb_m.Text.ToUpper());
Match match = Regex.Match(msg, @"\d|\s+");
if (match.Success)
{
MessageBox.Show("Only alphabetic characters and spaces are allowed.\nCheck the message for numbers, symbols or tab whitespace and remove them before continuing.\nAlso, \"W\" will be replaced by \"V\".", "Error: invalid chars in message");
MessageBox.Show("Only alphabetic characters, spaces, commas (,) and dots (.) are allowed.\nCheck the message for numbers, symbols or tab whitespace and remove them before continuing.\nAlso, \"W\" will be replaced by \"V\".", "Error: invalid chars in message");
return;
}
msg = msg.Replace("W", "V");
textBox5.Text = msg;
return;
}