예제 #1
0
        private void btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            string Sender = txtSender.Text;
            string body   = txtBody.Text;
            // RegEx: Sender = "@" followed by 1-15 characters (eg "@EdinburghNapier")
            string sPattern = "^[@]+\\w{1,15}$";

            // RegEx: Sender does not match sPattern
            if (!System.Text.RegularExpressions.Regex.IsMatch(Sender, sPattern))
            {
                // Invalid
                MessageBox.Show("Invalid", "Error");
            }

            // Check for mentions ("@Mention")
            checkMentions(body);
            // Check for hashtags ("#Hashtag")
            checkHashtags(body);

            // Get messageID
            string messageID = txtMessageID.Text;

            // Expand Abbreviations
            var Expand = new ExpandAbbreviations();

            Expand.expand(body, messageID, Sender);
            this.Hide();
        }
예제 #2
0
        private void btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            // This must be a phone number. Note that it is a string instead a numeric
            // variable.
            string Sender = txtSender.Text;

            // RegEx: Sender = 5 digits, followed by a dash, followed by 6 digits (eg. 12345-123456)
            string sPattern = "^\\d{5}-\\d{6}$";

            // RegEx: Sender matches sPattern
            if (System.Text.RegularExpressions.Regex.IsMatch(Sender, sPattern))
            {
                string body      = txtBody.Text;
                string messageID = txtMessageID.Text;

                // Expand abbreviations
                var Expand = new ExpandAbbreviations();
                Expand.expand(body, messageID, Sender);
                this.Hide();
            }
            else
            {
                MessageBox.Show("Please enter a valid phone number", "Error");   // Invalid phone number
            }
        }