Good afternoon, I’ve already climbed in Google, but I couldn’t find an answer to my question, I apologize if it’s too stupid, but I hope someone can help.
document whose content is
//----- (00000001) -------------------------------------------------------- some text //----- (00000002) -------------------------------------------------------- some text2 //----- (00000003) -------------------------------------------------------- I want to find a way to pull all the content between
//----- (00000001) -------------------------------------------------------- //----- (00000002) -------------------------------------------------------- where the numbers in the brackets are the key: I set the argument for example 00000005 and you need to get everything that is on the lines starting from the one where it will be found (00000005) and to the next character set //-----
if we serve
//----- (00000001) -------------------------------------------------------- some text2 //----- (00000002) -------------------------------------------------------- some text3 some text4 //----- (00000003) -------------------------------------------------------- and the argument 00000002 then on the output get
//----- (00000002) -------------------------------------------------------- some text3 some text4 I'm trying to do it on c #, but so far I just can't figure out how to get all the "from and to" lines
I just can not understand what expression to put in view of the conditions of the problem for Regex. Match (**)
as an argument for the search goes static string testArg = "00000001";
public static void Main(string[] args) { using (var outputFile = new StreamWriter(String.Format("output.c"))) { StreamReader file = new StreamReader("test.c"); string line; while ((line = file.ReadLine()) != null) { string matchText = Regex.Match(line, "((.*)//-----)").Value; outputFile.WriteLine("{0}", matchText); } } } but how I can’t find this search argument here;