如何从给定的字符串行中提取字符串? [英] How to extract string from a given line of strings ?

查看:75
本文介绍了如何从给定的字符串行中提取字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一个像这样的字符串

Hi,
I have a string like this

C:\TEMP\FDB2\27JUN2012.TEL136430D\NDDF PLUS DB\NDDF Plus DB

,我想从其中提取一个部分,例如

and I want to extract a part from this like

27JUN2012.TEL136430D

. Plz指南我该怎么做?

在此先感谢

. Plz Guide how can i do this ?

Thanks in advance

推荐答案

您可以使用String.Split将其分解为组件:
You could use String.Split to break it into teh components:
string inp = "C:\TEMP\FDB2\27JUN2012.TEL136430D\NDDF PLUS DB\NDDF Plus DB"
string[] parts = inp.Split('\\');


然后,这取决于路径的组织方式:如果它始终是您想要的第三部分,那么


Then it depends on how your paths will be organised: if it is always the third part you want, then

Console.WriteLine(parts[2]);

将其提供给您.否则,您将必须查看每个部分,并确定其是否符合您的标准.在不了解更多标准的情况下,我不能说!

Will give it to you. Otherwise, you will have to look at each part and see f it matches whatever your criteria are. Without knowing more about the criteria, I can''t say!



经历这个-
子字符串 [ ^ ]
C#字符串 [
Hi,
Go through this-
substring [^]
C# Strings[^]


字符串a =" C:\ TEMP \ FDB2 \ 27JUN2012.TEL136430D \ NDDF PLUS DB \ NDDF Plus DB"
string [] a = comment.Split(''\'');
msgbox.show(a [2]);
string a= "C:\TEMP\FDB2\27JUN2012.TEL136430D\NDDF PLUS DB\NDDF Plus DB"
string[] a = comment.Split(''\'');
msgbox.show(a[2]);


这篇关于如何从给定的字符串行中提取字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆