using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"<!--\s*ID\:\s*\d+\s*-->(?=\n*-\s+)";
string input = @"### Alias
Q: what check to do before creating an alias?
A: check whether any other command exists by that name using `type new-alias-name`
<!--ID: 1643091253375-->
---
Q: syntax to create an alias?
A: `alias name='string'`
<!--ID: 1645446702965-->
- no spaces before or after the equal sign
- single quotes around the command sequence
![[Pasted image 20220125092954.png]]
<!--ID: 1643091253408-->
---
### Redirection/Piping
Q: output of `> ls-output.txt`
A: the file will be truncated if it exists or it would be created.
<!--ID: 1645087988730-->
- Simply using the redirection operator with no command preceding it will truncate an existing file or create a new empty file
<!--ID: 1643351731943-->
";
RegexOptions options = RegexOptions.Multiline;
foreach (Match m in Regex.Matches(input, pattern, options))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
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