我正在使用扫描仪和分隔符来标记我的 .txt 文件(这是我必须做的功课)。该文件的第一个版本如下所示:
5,5,5,6,5,8,9,5,6,8, good, very good, excellent, good
7,7,8,7,6,7,8,8,9,7,very good, Good, excellent, very good
8,7,6,7,8,7,5,6,8,7 ,GOOD, VERY GOOD, GOOD, AVERAGE
9,9,9,8,9,7,9,8,9,9 ,Excellent, very good, very good, excellent
7,8,8,7,8,7,8,9,6,8 ,very good, good, excellent, excellent
6,5,6,4,5,6,5,6,6,6 ,good, average, good, good
7,8,7,7,6,8,7,8,6,6 ,good, very good, good, very good
5,7,6,7,6,7,6,7,7,7 ,excellent, very good, very good, very good
我使用useDelimiter("[ ]*(,)[ ]*")
的文件的第二个版本如下所示:
5 5 5 6 5 8 9 5 6 8 good, very good, excellent, good
7 7 8 7 6 7 8 8 9 7 very good, Good, excellent, very good
8 7 6 7 8 7 5 6 8 7 GOOD, VERY GOOD, GOOD, AVERAGE
9 9 9 8 9 7 9 8 9 9 Excellent, very good, very good, excellent
7 8 8 7 8 7 8 9 6 8 very good, good, excellent, excellent
6 5 6 4 5 6 5 6 6 6 good, average, good, good
7 8 7 7 6 8 7 8 6 6 good, very good, good, very good
5 7 6 7 6 7 6 7 7 7 excellent, very good, very good, very good
而且我想不出一个正则表达式来帮助我用空格分隔数字和用逗号分隔单词。基本上我需要一个有 14 个值的数组(非常好是一个变量)
注意有多个空格(这样做是为了让我们更难)。
因此,我们将不胜感激任何形式的帮助。
PS我们只允许使用分隔符(没有分割等..)