Update (parsing): skip words below 120

This commit is contained in:
2023-11-29 12:24:15 +08:00
parent c70b0bccd4
commit 8c0ae63f42
3 changed files with 24 additions and 1 deletions

View File

@@ -3,6 +3,20 @@
use Carbon\Carbon;
use Illuminate\Support\Str;
if (! function_exists('count_words')) {
function count_words($string) {
// Remove punctuation and line breaks
$cleanString = preg_replace('/[\p{P}\s]/u', ' ', $string);
// Split the string into words
$words = preg_split('/\s+/', $cleanString, -1, PREG_SPLIT_NO_EMPTY);
// Count the words
return count($words);
}
}
if (! function_exists('dmy')) {
function dmy(Carbon $carbon)
{