25 'on',
'in',
'at',
'since',
'for',
'ago',
'before',
'to',
'past',
'till',
'until',
'by',
'under',
'below',
26 'over',
'above',
'across',
'through',
'into',
'towards',
'onto',
'from',
'of',
'off',
'about',
'via'
34 'yet',
'so',
'just',
'only'
38 'nor',
'so',
'and',
'or'
79 $wordArray = explode(
" ", $text);
81 array_walk($wordArray,
function (&$word) {
82 $word = ucfirst($word);
85 return implode(
" ", $wordArray);
94 if (preg_match(
'/(.+[^<>][\.:\/;\?\!]\s?)([a-z])(.+)/', $titleString, $match)) {
95 $titleString = $match[1].StringHelper::mb_ucfirst($match[2]).$match[3];
98 $wordArray = explode(
" ", $titleString);
100 array_walk($wordArray,
function (&$word) {
101 $words = explode(
"-", $word);
102 if (count($words) > 1) {
103 array_walk($words,
function (&$w) {
106 $word = implode(
"-", $words);
111 return implode(
" ", $wordArray);
121 return in_array($word, self::PREPOSITIONS) ||
122 in_array($word, self::ARTICLES) ||
123 in_array($word, self::CONJUNCTIONS) ||
124 in_array($word, self::ADJECTIVES) ||
125 (bool) preg_match(
"/[^\p{L}].+/", $word);
133 public static function mb_ucfirst($string, $encoding =
'UTF-8')
135 $strlen = mb_strlen($string, $encoding);
136 $firstChar = mb_substr($string, 0, 1, $encoding);
137 $then = mb_substr($string, 1, $strlen - 1, $encoding);
141 return in_array($encoding, self::ISO_ENCODINGS) ?
148 for ($i = mb_strlen($string); $i >= 0; --$i) {
149 $result .= mb_substr($string, $i, 1);
161 $delim = trim($delimiter);
162 if (!empty($delim)) {
163 foreach ($arrayOfStrings as $key => $textPart) {
166 $length = mb_strlen($textPart) - mb_strlen($delim);
167 $textPart = mb_substr($textPart, 0, $length);
168 $arrayOfStrings[$key] = $textPart;
172 return implode($delimiter, $arrayOfStrings);
184 $exploded = explode(
"-", $string);
186 foreach ($exploded as $explode) {
187 $spaceExploded = explode(
" ", $explode);
188 foreach ($spaceExploded as $givenPart) {
189 $firstLetter = mb_substr($givenPart, 0, 1,
"UTF-8");
191 $res .= ctype_upper($firstLetter) ? $firstLetter.$initializeSign :
" ".$givenPart.
" ";
193 $res .= $firstLetter.$initializeSign;
196 if ($i < count($exploded) - 1 && $initializeWithHyphen) {
197 $res = rtrim($res).
"-";
210 $hyphenated = preg_replace(
"/([A-Z])/",
"-$1", $string);
211 $hyphenated = substr($hyphenated, 0, 1) ===
"-" ? substr($hyphenated, 1) : $hyphenated;
212 return mb_strtolower($hyphenated);
221 return ($string === mb_strtolower($string));
230 return ($string === mb_strtoupper($string));
239 return preg_replace(
"/\'/",
"’", $string);
259 if (preg_match(
"/(.*)$outerOpenQuote(.+)$outerCloseQuote(.*)/u", $text, $match)) {
260 return $match[1].$innerOpenQuote.$match[2].$innerCloseQuote.$match[3];
271 return boolval(preg_match_all(
"/^[\p{Latin}\p{Common}]+$/u", $string));
281 return boolval(preg_match(
"/^[\p{Cyrillic}\p{Common}]+$/u", $string));
290 return boolval(preg_match(
"/^[\p{Han}\s\p{P}]*$/u", $string));
300 return str_replace([
"[",
"]",
"(",
")",
"{",
"}"],
"", $datePart);