Hi @Kmcnet , Welcome to Microsoft Q&A,
If you mean using regular expressions to split, you can use it like this:
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace xxx
{
internal class Program
{
static void Main(string[] args)
{
string input = "(01)00358160740213(17)260515(10)32PF3(21)5HZ6R1PX8C";
// Define the regular expression pattern to match the GS1 separator and its value
string pattern = @"\((\d{2})\)([^\(]+)";
var matches = Regex.Matches(input, pattern);
// Create a dictionary to store the parsing results
var parsedData = new Dictionary<string, string>();
foreach (Match match in matches)
{
// Group 1 is the separator, group 2 is the corresponding value
string key = match.Groups[1].Value;
string value = match.Groups[2].Value;
parsedData[key] = value;
}
Console.WriteLine("Analysis results:");
foreach (var item in parsedData)
{
Console.WriteLine($"Delimiter: {item.Key}, Value: {item.Value}");
}
Console.ReadLine();
}
}
}
Best Regards,
Jiale
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.