I want remove some part of text using regular expression in c#. Text looks like that:
BEGIN:VNOTE
VERSION:1.1
BODY;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:Penguins are among the most popular of all birds. They only live in and around the South Pole and the continent of Antarctica.No wild penguins live at the North Pole. There are many different kinds of penguins. The largest penguin is called the Emperor Penguin, and the smallest kind of penguin is the Little Blue Penguin. There are 17 different kinds of penguins in all, and none of them can fly
As the result I want to remove from text part
BEGIN:VNOTE
VERSION:1.1
BODY;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:
Text between BEGIN and PRINTABLE: can be different.
So I wrote code (last version):
var start = "BEGIN";
var end = "PRINTABLE:";
var regEx = string.Format("{0}(.*|\n){1}", start, end);
var result = Regex.Replace(sourceText, regEx, string.Empty);
But it doesn't work. I tried many different variants of regex with the same result. Any ideas how my regex should looks?
Thank you for any advice.
emptystring. That would be simpler.(.*|\n)part to achieve? It will match either the.*or the single character\n. It may not even match the\nbecause normally it would be written as\\nwithin a regular expression. Another option is to use the@"..."syntax for strings.