using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(\""[^\""]+\""|[^\|\>\<\:\s\""]+)([^\|\<\>\n\r]*)(\||\>.*)?";
string substitution = @"\1";
string input = @"Illeszkedjen:
Alapesetek:
cat ezmeg.az | grep ""azta"" | sort -n > ez.txt
cat ezmeg.az | grep ""az ta"" | sort -n > ez.txt
head -n 1 -r text.txt > head.txt
head -n 1 text.txt
head text.txt | tail
ls
Extrém esetek:
cat ezmeg.az |sort -n > ez.txt
cat ezmeg.az |sort -n | sort -n | sort -n> ez.txt
cat ezmeg.az |grep ""azta"" | sort -n > ez.txt
cat ezmeg.az -n --help | grep ""azta"" | sort -n -h > ez.txt
cat ezmeg.az | azta.exe | sort -n > ez.txt
cat ezmeg.az | grep ""azta"" | sort -n
cat ezmeg.az | grep ""azta"" | sort -n > ez.txt
cat ezmeg.az | grep ""azta"" | sort -n>ez.txt
""my program.exe"" --help > help.txt
head -n 1 text.txt > ""head file.txt""
Ne illeszkedjen:
head -n 1 text.txt > head.txt -x
head -n 1 text.txt > head.txt | tail
";
Regex regex = new Regex(pattern);
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