gpt4 book ai didi

c# - 如何从文本中删除多个点 (.)?

转载 作者:太空宇宙 更新时间:2023-11-03 11:41:03 25 4
gpt4 key购买 nike

如何从文本中删除多个点 (.)?

例如:

123..45  = 123.45
10.20.30 = 10.2030
12.34 = 12.34
12.. = 12
123...45 = 123.45

怎么做?

提前致谢

最佳答案

不是必须使用正则表达式,你可以通过这种方式实现你需要的:

 string s = "10.20.30";
int n;
if( (n=s.IndexOf('.')) != -1 )
s = string.Concat(s.Substring(0,n+1),s.Substring(n+1).Replace(".",""));

关于c# - 如何从文本中删除多个点 (.)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4795483/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com