.net - Parse filename from full path using regular expressions in C# -


how pull out filename full path using regular expressions in c#?

say have full path c:\cooldirectory\coolsubdirectory\coolfile.txt.

how out coolfile.txt using .net flavor of regular expressions? i'm not regular expressions, , regex buddy , me couldn't figure 1 out.

also, in course of trying solve problem, realized can use system.io.path.getfilename, fact couldn't figure out regular expression making me unhappy , it's going bother me until know answer is.

//  using system.text.regularexpressions;  /// <summary> ///  regular expression built c# on: tue, oct 21, 2008, 02:34:30 pm ///  using expresso version: 3.0.2766, http://www.ultrapico.com ///   ///  description of regular expression: ///   ///  character not in class: [\\], number of repetitions ///  end of line or string ///   /// /// </summary> public static regex regex = new regex(       @"[^\\]*$",     regexoptions.ignorecase     | regexoptions.cultureinvariant     | regexoptions.ignorepatternwhitespace     | regexoptions.compiled     ); 

update: removed beginning slash


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -