本文介绍了只读文本文件中的整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好
我的问题是说我在文本文件中有一个名称为"test.txt"的文本文件,它具有"1ab2n3",首先我想从文本文件中仅读取整数(123),然后其余字符即(abn)是可能的第二个方法是我尝试了很多东西file.Io.readalllines etc
Hello
my question is lets say i have a text file with a name "test.txt" inside text file it has "1ab2n3"first i want to read only integers(123) from text file,then the remaining character i-e(abn)Is it possible secondly how to do it i have tried so many things file.Io.readalllines etc
推荐答案
string myStr = "1ab2n3";
string myNumberResult = Regex.Replace(myStr, @"[^\d]", "");
string myCharResult = Regex.Replace(myStr, @"[\d]", "");
希望能有所帮助.如果是这样,请将其标记为答案/赞.
-Milind
Hope that helps. If it does, mark the it as answer/upvote.
-Milind
这篇关于只读文本文件中的整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!