Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 11661

C# regex parse text multiline sections

$
0
0

colleagues.
I know , it looks not very complicated, but I could not complete this task.
I have this type multiline text:

"Analyst","""Date Started","08:09 13/12/2023  GMT: 08:09 13/12/2023""Method: Any text here (Flame)""CCU-1e",2.5234,"""Artificial STD  0.5%",9.7820,"""",-0.2780,"""Method: Al Fusion (Acid)""CCU-1E  6%",58.9970,"e""Artificial STD  6%",60.4934,"""Artificial STD  9%",90.3649,"""",-0.2780,"""Method: Cruc Fusion (Flame)""Artificial STD  1%",19.9854,"""Artificial STD  9%",90.3649,"""",-0.2780,""

I would like to receive every "Method" section, i.e. all text between after a line with keyword "Method: ANY TEXT" and up to the next line with word "Method: ANY TEXT" OR end of text.So for present example I expect to have three matches:

  1. Section 1.
"CCU-1e",2.5234,"""Artificial STD  0.5%",9.7820,"""",-0.2780,""
  1. Section 2.
"CCU-1E  6%",58.9970,"e""Artificial STD  6%",60.4934,"""Artificial STD  9%",90.3649,"""",-0.2780,""
  1. Section 3.
"Artificial STD  1%",19.9854,"""Artificial STD  9%",90.3649,"""",-0.2780,""

I tried to implement this like: https://regex101.com/r/Wg3aFQ/1

But it's ugly and does not parse the middle section.

Thanks for your advices.


Viewing all articles
Browse latest Browse all 11661

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>