1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
   |  
            string pattern = @"\b[^ ]+\.LNK\b";
 
            // Initialisation de la Regex avec option ignorant la casse (accepte EXE, exe etc...)
            Regex r = new Regex(pattern,RegexOptions.IgnoreCase);
 
            // On récupère la première correspondance qui matche le pattern.
            Match m = r.Match(input);
            Console.WriteLine(m.Value);
 
            //SI IL Y A PLUSIEURS OCCURRENCES A RÉCUPÉRER :
            // On récupère les groupes qui matchent le pattern
            var matches = r.Matches(input);
 
            // On boucle sur la collection des occurrences.
            foreach (Match match in matches)
            {
                Console.WriteLine(match + Environment.NewLine);
            } | 
Partager