Потрібно знайти ці вставки і отримати число.
C#
using System.Text.RegularExpressions; string pattern = @"\{\{(.*?)\}\}"; foreach (Match match in Regex.Matches("text text {{111}} text {{112}} text", pattern)) if (match.Success && match.Groups.Count > 0) { string text = match.Groups[1].Value; Console.WriteLine(text); }
string sentence = "Employee name is [{#john#}], works for [{#ABC BANK#}], [{#Houston#}]"; string pattern = @"\[\{\#(.*?)\#\}\]"; foreach (Match match in Regex.Matches(sentence, pattern)) { if (match.Success && match.Groups.Count > 0) { var text = match.Groups[1].Value; Console.WriteLine(text); } } Console.ReadLine();
© accounting.org.ua - 2024