0

enter image description here

  • I will create a parametric structure
  • I will take after each '#' with its extension.
  • For example here I need to get two texts after #
Markus Meyer
  • 3,327
  • 10
  • 22
  • 35

1 Answers1

1
string text = "#sdvdsv0..-+mk?/!|°¬  *$%&()oO###sdfv684618awer6816";

string[] results = Regex.Split(text, "#+").Where(s => s != String.Empty).ToArray<string>(); 

Full example on a .net 6.0 console:

using System.Text.RegularExpressions;

string text = "#sdvdsv0..-+mk?/!|°¬  *$%&()oO###sdfv684618awer6816";

string[] results = Regex.Split(text, "#+").Where(s => s != String.Empty).ToArray<string>(); 

foreach (var x in results)
{
    Console.WriteLine(x);
}

Output:

sdvdsv0..-+mk?/!|°¬  *$%&()oO
sdfv684618awer6816

Use "#" to match only a single # character.

Use "#+" to match at least once with the # character

joseph l
  • 51
  • 7