我目前正在制作一个总结文字的程序。我有一个问题,如果你把它放入格式化的东西,它在输出中的格式相同。例如,如果你把:
This is a test.
New line here. This isn't a new line.
然后你会得到:
This is a test.
New line here. This isn't a new line.
虽然我希望程序输出:
This is a test. New line here. This isn't a new line.
查看单个句子的输出,看起来也有点奇怪:
2012-09-23 12:21:43.761 Program[5877:303] This is a test
2012-09-23 12:21:43.761 Program[5877:303]
New line here
2012-09-23 12:21:43.762 Program[5877:303] This isn't a new line
通常情况下,句子前不会有新行。虽然我不希望发布我的算法的代码,但它的基本原理是它通过标点符号对句子进行分离,对它们执行测试,将好的代码重新组合在一起,然后将其输出到NSTextView 。有没有办法从字符串或NSTextView输出中删除所有格式?