C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,336 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have multiple lines of text in a text document that are as follows;
21) 3000.5 Rx 0011 8 0E 00 00 00 C3 3C D4 FF
I need to snip each line like below;
0011 8 0E 00 00 00 C3 3C D4 FF
and past all the snippets into a textbox.
can anyone help
You could use regex provided the format of each line is the same as the above:
using System.Text.RegularExpressions;
var input = @"
21) 3000.5 Rx 0011 8 0E 00 00 00 C3 3C D4 FF
21) 3000.5 Rx 0011 8 0E 00 00 00 C3 3C D4 FE
21) 3000.5 Rx 0011 8 0E 00 00 00 C3 3C D4 FD
";
var results = new Regex(@"^\s*\d+\)\s+[\d.]+\s+Rx\s+(.+)$", RegexOptions.Multiline).Matches(input)
.Select(m => m.Groups[1].Value.Trim().Replace(" ", " "))
.ToArray();
foreach (var result in results) {
Console.WriteLine(result);
}
Which produces:
0011 8 0E 00 00 00 C3 3C D4 FF
0011 8 0E 00 00 00 C3 3C D4 FE
0011 8 0E 00 00 00 C3 3C D4 FD