Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/269.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何从文件名中提取Guid?_C#_Regex_Guid - Fatal编程技术网

C# 如何从文件名中提取Guid?

C# 如何从文件名中提取Guid?,c#,regex,guid,C#,Regex,Guid,我想从下面的字符串数组中提取Guid,并希望输出如下: Output:Log.txt,Logging.txt string[] str = new string[] { "1250a2d5-cd40-4bcc-a979-9d6f2cd62b9fLog.txt", "bdb31966-e3c4-4344-b02c-305c0eb0fa0aLogging.txt" }; //file name are Log.txt and Logging.txt List<string> list=

我想从下面的字符串数组中提取Guid,并希望输出如下:

Output:Log.txt,Logging.txt

string[] str = new string[] { "1250a2d5-cd40-4bcc-a979-9d6f2cd62b9fLog.txt", "bdb31966-e3c4-4344-b02c-305c0eb0fa0aLogging.txt" }; //file name are Log.txt and Logging.txt
List<string> list= new List<string>();
foreach (var item in str)
{
    if (!string.IsNullOrEmpty(item))
    {
        list.Add();  // here i want to store Log.txt and Logging.txt
    }
}
怎么做

var str = new string[] { "1250a2d5-cd40-4bcc-a979-9d6f2cd62b9fLog.txt", "bdb31966-e3c4-4344-b02c-305c0eb0fa0aLogging.txt" }; //file name are Log.txt and Logging.txt

var arr = str.Select(s=>s.Substring(36)).Where(s=>s.Any()).ToArray();

您可以在这里看到它的作用:

list.AddLog.txt:那么您确定guid只有36位吗?guid是128位,或者是32个十六进制字符。在这个特殊的表示法中,有4个额外的破折号-等于36!谢谢你提供的信息和解决方案。我能知道你的帖子上的否决票的原因吗?可能是因为它不是很清楚,也不是很专业。好吧,这个问题怎么说:这个问题很专业?