Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text.RegularExpressions;
- namespace _03ExtractFile
- {
- class Program
- {
- static void Main(string[] args)
- {
- string path = Console.ReadLine();
- string pattern = @"(?<=^|\\)(?<group2>[\w.]{1,})$";
- var regex = Regex.Matches(path, pattern);
- foreach (Match element in regex)
- {
- var file = element.Groups["group2"].Value;
- string[] fileAsArray = file.Split(".");
- string filename = fileAsArray[0];
- string extension = fileAsArray[1];
- Console.WriteLine($"File name: {filename}");
- Console.WriteLine($"File extension: {extension}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement