Untitled
Kulin 13 28th Feb, 2025
using System;
using System.Text.RegularExpressions;
class Program
{
static void Main()
{
string input = "To jest przykładowy tekst 12345 z liczbami.";
string result = AddLinkToFirstNumber(input);
Console.WriteLine(result);
}
static string AddLinkToFirstNumber(string input)
{
if (string.IsNullOrEmpty(input))
return input;
// Znalezienie pierwszego ciągu cyfr
Match match = Regex.Match(input, @"\d+");
if (match.Success)
{
string number = match.Value;
string link = string.Format("<a href='https://example.com/{0}'>{0}</a>", number);
// Ręczna zamiana pierwszego wystąpienia liczby
int index = input.IndexOf(number);
if (index != -1)
{
return input.Substring(0, index) + link + input.Substring(index + number.Length);
}
}
return input;
}
}
To share this paste please copy this url and send to your friends
RAW Paste Data
Recent Pastes
- Untitled
Markup | 21 | 7 hours ago
- женский брендовый рубашка купить
Parser | 8 | 13 hours ago
- Untitled
Markup | 13 | 17 hours ago
- Untitled
Markup | 12 | 17 hours ago
- Заказать Москитную Сетку На Пластиковое Окно
IO | 7 | 18 hours ago
- True Videos
Markup | 19 | 1 day ago
- Untitled
Markup | 19 | 1 day ago