'Once upon a time in a world far far away'.truncate(27) "Once upon a time in a wo..." 'Once upon a time in a world far far away'.truncate(27, separator: ' ') "Once upon a time in a..." 'Once upon a time in a world far far away'.truncate(27, separator: /\s/) "Once upon a time in a..." 'And they found that many people were sleeping better.'.truncate(25, omission: '... (continued)') "And they f... (continued)"
You can also see this example.
truncate
Himanshu patel
source share