0
A
回答
0
按照文檔:
truncate("Once upon a time in a world far far away", length: 17)
# => "Once upon a ti"
truncate("Once upon a time in a world far far away", length: 17, separator: ' ')
# => "Once upon a"
請找到更多關於這在下面的SO鏈接:
Truncate a string without cut in the middle of a word in rails
相關問題
- 1. 截斷字符串
- 2. 截斷字符串
- 3. 的WriteFile()截斷字符串
- 4. 字符串截斷的ClientDataSet
- 5. Powershell - 截斷字符串中的字符
- 6. KRL:截斷字符串
- 7. RODBC字符串被截斷
- 8. UILabel字符串截斷
- 9. 腳本截斷字符串
- 10. BufferedWriter將截斷字符串
- 11. 截斷字符串錯誤
- 12. Powershell截斷字符串
- 13. PHP截斷字符串
- 14. Python截斷長字符串
- 15. 截斷字符串在Javascript
- 16. pad /截斷字符串
- 17. 截斷在python字符串
- 18. postgresql截斷字符串
- 19. x個字符後截斷字符串
- 20. 按字節截斷字符串
- 21. Rails截斷包含&eacute的UTF-8字符串; (例如)
- 22. 截斷並展開Ruby On Rails中的字符串
- 23. 使用的sscanf()截斷字符串
- 24. 截斷沒有空白的字符串
- 25. android spinners中的截斷字符串
- 26. 截斷要保存的字符串?
- 27. 截斷sharepoint中的文本字符串
- 28. 的JavaScript字符串截斷逗號
- 29. 使用截斷字符串替換數組中的字符串
- 30. Base64encode圖像字符串被截斷
您可以使用分離選項。 請訪問:http://stackoverflow.com/questions/8714045/truncate-a-string-without-cut-in-the-middle-of-a-word-in-rails – dp7