using System.Text.RegularExpressions;
using System.Windows.Forms;
public partial class MainForm : Form
private void btnFindMaxNumber_Click(object sender, EventArgs e)
string inputText = txtInput.Text;
int maxNumber = FindMaxNumber(inputText);
txtResult.Text = $"Максимальне ціле число: {maxNumber}";
private int FindMaxNumber(string input)
Regex regex = new Regex(@"\b\d+\b");
MatchCollection matches = regex.Matches(input);
int maxNumber = int.MinValue;
foreach (Match match in matches)
if (int.TryParse(match.Value, out number))