Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regex for extracting certain part of a String

Tags:

c#

.net

regex

Hey Im trying to extract certain information from a string. The String looks like

Name: music mix.mp3 Size: 2356KB

I would like to extract the file name only with the extension.
I dont have much knowledge in regex, so I was hoping to get some help here. Thanks!

like image 268
Ravana Avatar asked Apr 13 '11 14:04

Ravana


1 Answers

Please check this example:

const string str = "Name: music mix.mp3 Size: 2356KB";
var match = Regex.Match(str, "Name: (.*) Size:");
Console.WriteLine("Match: " + match.Groups[1].Value);
like image 54
Alex Netkachov Avatar answered Sep 28 '22 03:09

Alex Netkachov