这里的一项产出要求进行多次评价,但得到我想要做的工作(删除除案文外的一切)。
words = IO.read("file.txt").
gsub(/s/, ""). # delete white spaces
gsub(".",""). # delete periods
gsub(",",""). # delete commas
gsub("?","") # delete Q marks
puts words
# output
# WheninthecourseofhumaneventsitbecomesnecessaryIwanttobelieveyoureallyIdobutwhoamItoblameWhenthefactsarecountedthenumberswillbereportedLotsoflaughsCharlieIthinkIheardthatonetentimesbefore
看看这个员额————我表示,如果不进行多次考试,我将尽力取得相同结果。 但我没有获得同样的产出。
words = IO.read("file.txt").
match(/(w*)+/)
puts words
# output - this only gets the first word
# When
这只是第一句:
words = IO.read("file.txt").
match(/(...*)+/)
puts words
# output - this only gets the first sentence
# When in the course of human events it becomes necessary.
任何关于获得相同产出的建议(包括排除白天空间和非口号)与相对比的建议?