using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"^(?!(?:\s*$|.*(?:Niveau|stime)))(.*$)([\s\S]*?)(\1\s*)";
string substitution = @"\1\2";
string input = @"vide vide Time: stime 3:30 PM vide vide
NN NN NP stime LS NP NN NN
----------Niveau 1--------------
Time: | 0 | 263.0 | 266.0 | 0,0113
NP | 0 | 0.0 | 24885.0 | 1
3:30 | -0 | 104.0 | 120.0 | 0,1333
LS | -0 | 0.0 | 13134.0 | 1
PM | -1 | 134.0 | 238.0 | 0,437
NP | -1 | 0.0 | 24885.0 | 1
----------Niveau 2--------------
3:30 PM | -0 | 30.0 | 41.0 | 0,2683
3:30 NP | -0 | 133.0 | 55.0 | -1,4182
LS PM | -0 | 42.0 | 237.0 | 0,8228
LS NP | -0 | 0.0 | 2456.0 | 1
----------Niveau 3--------------
vide vide Time: stime 3:30 pm vide vide
NN NN NP stime LS NN NN NN
----------Niveau 1--------------
Time: | 0 | 263.0 | 266.0 | 0,0113
NP | 0 | 0.0 | 24885.0 | 1
3:30 | -0 | 104.0 | 120.0 | 0,1333
LS | -0 | 0.0 | 13134.0 | 1
pm | -1 | 38.0 | 54.0 | 0,2963
NN | -1 | 0.0 | 59511.0 | 1
----------Niveau 2--------------
3:30 pm | -0 | 9.0 | 9.0 | 0
3:30 NN | -0 | 36.0 | 24.0 | -0,5
LS pm | -0 | 22.0 | 52.0 | 0,5769
LS NN | -0 | 0.0 | 2658.0 | 1
----------Niveau 3-------------- ";
RegexOptions options = RegexOptions.Multiline;
Regex regex = new Regex(pattern, options);
string result = regex.Replace(input, substitution);
}
}
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