Example #1
0
 private void StartBtn_Click(object sender, RoutedEventArgs e)
 {
     RegexTb.Items.Add(RegexTb.Text);
     _lists.Clear();
     if (string.IsNullOrWhiteSpace(MatchTb.Text)) return;
     _regex = new RegexAnalyze(MatchTb.Text, RegexTb.Text);
     _regex.Match();
     foreach (Match item in _regex.Matches)
     {
         _lists.Add(new MatchItem(item));
     }
     Listbox.ItemsSource = _lists;
     CountLb.Text = "添加了 " + _lists.Count.ToString(CultureInfo.InvariantCulture) + " 条数据";
 }
Example #2
0
 private void RegexTb_KeyDown(object sender, KeyRoutedEventArgs e)
 {
     if (e.Key != Windows.System.VirtualKey.Enter)
     {
         return;
     }
     if (string.IsNullOrWhiteSpace(RegexTb.Text) || string.IsNullOrWhiteSpace(ContentTb.Text))
     {
         return;
     }
     MainPivot.SelectedIndex = 1;
     MatchList.Items.Clear();
     _regex = new RegexAnalyze(ContentTb.Text, RegexTb.Text);
     _regex.Match();
     foreach (Match item in _regex.Matches)
     {
         if (item.Groups.Count < 2)
         {
             MatchList.Items.Add(item.Value);
             continue;
         }
         var arg = new StringBuilder();
         arg.AppendLine(item.Value);
         for (int i = 0; i < item.Groups.Count; i++)
         {
             var group = item.Groups[i];
             arg.AppendLine(i.ToString() + "\t" + group.Value);
             if (group.Captures.Count < 2)
             {
                 continue;
             }
             for (int j = 0; j < group.Captures.Count; j++)
             {
                 arg.AppendLine(j.ToString() + "\t\t" + group.Captures[j].Value);
             }
         }
         MatchList.Items.Add(arg.ToString());
      }
 }