.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

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

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

unit testing - How to mock PreferenceManager in Android? -