我有一个文本文件,我想用这样的记录来解析:
===================
name: John Doe
Education: High School Diploma
Education: Bachelor's Degree
Education: Sun Java Certified Programmer
Age: 29
===================
name: Bob Bear
Education: High School Diploma
Age: 18
===================
name: Jane Doe
Education: High School Diploma
Education: Bachelor's Degree
Education: Master's Degree
Education: AWS Certified Solution Architect Professional
Age: 25
如您所见,fields此类文本文件中的是固定的,但其中一些重复了任意多次。记录由固定长度的====定界符分隔。
我将如何为此类问题编写解析逻辑?我想使用switch它来读取行的开头,但是处理多个重复字段的逻辑使我感到困惑。
白猪掌柜的
相关分类