如何删除字符串的部分字符

xmrforever 2012-12-20 04:35:36
我现在有一个字符串,比如"00938723940F12.983921Z"
我现在要取出这个字符串中F和Z之间的浮点数
如果没有F之前的一串数据,我用Split可以把这个浮点数提取出来
请教大家如何把F之前的数据删掉,或者另有方法取这个浮点数都可以
...全文
133 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
xmrforever 2012-12-21
  • 打赏
  • 举报
回复
引用 4 楼 ttgss 的回复:
Substring 也行
具体怎么用可以介绍一下吗
ttgss 2012-12-20
  • 打赏
  • 举报
回复
Substring 也行
xmrforever 2012-12-20
  • 打赏
  • 举报
回复
引用 1 楼 bdmh 的回复:
正则 C# code?1234 string source = "00938723940F12.983921Z"; Regex reg = new Regex(@"(?<=F).*?(?=Z)"); Match mm = reg.Match(source); MessageBox.……
正解,补充一下 要加一个引用集using System.Text.RegularExpressions;
  • 打赏
  • 举报
回复
string str = "00938723940F12.983921Z"; str = Regex.Match(str, @"(?<=[a-zA-Z]+)\d+(\.\d+)?").Value;
bdmh 2012-12-20
  • 打赏
  • 举报
回复
正则

            string source = "00938723940F12.983921Z";
            Regex reg = new Regex(@"(?<=F).*?(?=Z)");
            Match mm = reg.Match(source);
            MessageBox.Show(mm.Value);

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧