Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何动态验证固定宽度的文件?
如果用户以这种方式通过它,我可以毫无问题地阅读它
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 reg = new Regex("\d{3}\-\d{2}\-\d{4}\s+[a-zA-Z]+\s+\d+\s+\d+");
检查语法,因为我直接输入