如何从字符串中删除值 [英] How to cut the value from a string

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

问题描述



我在字符串中有一个值,例如

Hi,

I have a value in string like

string str="stat-1-1-2:ttf_3l2-1: 0:35:11:34";


我期望输出是"1-1-2";

问候,
Basha


I am expecting the output is "1-1-2";

Regards,
Basha

推荐答案

使用文档 [ ^ ] MSDN学习如何拆分字符串并从中提取特定细节.很好地学习它,因为您在整个编程生涯中都将需要它.不学习它,您的职业生涯可能很短.
Use the documentation[^] on MSDN to learn how to split strings and extract specific details from them. Learn it well as you will need it throughout your programming career. Don''t learn it, and your career is likely to be very short.


string x=str.split(':')[0].tostring();


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

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