Imports System.Text Imports System.Text.RegularExpressions Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim reg As New Regex("ma(?<gp>\d+)") Dim res As New StringBuilder For Each itm In (From a In reg.Matches(TextBox1.Text).OfType(Of Match) Select gp = a.Groups("gp").Value Group By gp Into cnt = Count) res.Append($"ma{itm.gp}:{itm.cnt}回 ") Next TextBox2.Text = res.ToString End Sub End Class