using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"\#.*?(?=\s|\n|\#|$)";
string input = @"#3!x_j@`(/l3W#qfSnl#6R7x1b,jBb0p#Oq/:o#!tH3AITK^Yyp#B,
#qwe#%#T &#v#v#N###O###2#` `S}^&9 #M # Aa23%2##p#?#w#a
#123#9#Z a%h#&#C###;###? a#u#g#Q#r#8# #a#A#l#p#r#b#}#c
#R#M#(#p###K###l###1###b 2#D\'>.w/Y_2 sha2&2{] #4x$D~kR
#lbTb1k3# #Dlo ## #j# #W H#tjsR.Lzkc #B*xt&nFty?il#jp
#>p8BTU2###PW!aB###z###-VM (s82hdk#T 8sUJWfuy2#-#f~fh)
#d{jyi|^ofYD#q)!#special~!@$%^&*()#_+`-=[];\',./?><\"":}{";
foreach (Match m in Regex.Matches(input, pattern))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx