Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 上载固定宽度文件并验证固定宽度格式是否为c中的正确格式#_C#_Asp.net - Fatal编程技术网

C# 上载固定宽度文件并验证固定宽度格式是否为c中的正确格式#

C# 上载固定宽度文件并验证固定宽度格式是否为c中的正确格式#,c#,asp.net,C#,Asp.net,如何动态验证固定宽度的文件 如果用户以这种方式传递它,我可以毫无问题地阅读它 123-45-6789 Nick Sanders 200 300 987-65-4321 Jon Smith 400 550 如果他们以下面的方式给出,我如何验证和阅读 123-45-6789 Nick Sanders 200 300 987-65-4321 Jon Smith 400 550 987-65-4321 Jon Smith 400 550 使用regex类来验证它 Re

如何动态验证固定宽度的文件

如果用户以这种方式传递它,我可以毫无问题地阅读它

123-45-6789 Nick Sanders 200 300
987-65-4321 Jon  Smith   400 550
如果他们以下面的方式给出,我如何验证和阅读

123-45-6789 Nick Sanders     200 300
987-65-4321 Jon  Smith     400 550
987-65-4321 Jon  Smith   400 550

使用regex类来验证它

 Regex reg = new Regex("\d{3}\-\d{2}\-\d{4}\s+[a-zA-Z]+\s+\d+\s+\d+");

检查语法,因为我直接键入了它

这个固定宽度是多少?你是说分隔符吗?不,这是一个固定宽度的文件,不是分隔符。