vanderlee / php-sentence

Simple text sentence splitting and counting. Supports atleast english, german and dutch, possibly more. If you find it works well enough for your language, please let me know!
MIT License
78 stars 23 forks source link

Simplify multibyte trimming. Fixes #27 #28

Closed splitbrain closed 7 months ago

splitbrain commented 1 year ago

Instead of trying to trim the string from both ends, keeping the middle intact by referencing it, this applies two operations on the left and right separately.

Since both regexes are anchored and no references have to be kept it shouldn't be any slower than before and I suspect it might even be faster (though I have not benchmarked it).

It is more robust for sure and passes my (limited) test case.

vanderlee commented 7 months ago

Fixed using alternative solution and improved unittests