using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(?<!\d{8})_(?!\d{6})";
string substitution = @".";
string input = @"Patate_17890505_TitreEnCamelCase.ext
EPFL_AlgebreLineaire
TaxonomieProprietesFonctionsComplexes.v0.ipe.20210302_005606.pdf
1_
12_
_1
_12
12345678_
_123456
12345678_12345
1234567_123456
1234567_12345
123456_12345
12345678_1234567
123456789_123456
123456789_1234567
_patate__truc__
___
foo_12345678
foo_12345678_123456_bar
12345678_123456
foo12345678_123456bar";
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