Capitalize first letters.

@param string $string

@return string
969732
private static function capitalize($string)
    {
        $string = mb_strtolower($string);

        $string = mb_ereg_replace_callback('\b\w', function ($matches) {
            return mb_strtoupper($matches[0]);
        }, $string);

        // Lowercase 's
        $string = mb_ereg_replace_callback('\'\w\b', function ($matches) {
            return mb_strtolower($matches[0]);
        }, $string);

        return $string;
    }
519839
protected function sensible($string)
    {
        $string = preg_replace('`([A-Z])`', '-\1', $string);
        $string = str_replace(array('-', '_'), ' ', $string);

        return ucfirst(trim(strtolower($string)));
    }
631357
public static function sentence($string) {
    $pieces = explode(' ', $string);

    // Put the first word into lowercase, unless it's all capitals.
    if (!preg_match('@^[[:upper:]]+$@', $pieces[0])) {
      $pieces[0] = lcfirst($pieces[0]);
    }

    return new StringAssembler($pieces);
  }
849505
public static function upperCaseTitle($string){

		// Only transform to lowercase if title is more than a single word

		if(strpos($string, ' ') !== false){

			if(strtoupper($string) == $string) $string = strtolower($string);
		}

		$string = ucwords($string);

		$string = str_replace(self::_getAdpositions(),
			self::_getAdpositions(true), $string);

		return ucfirst($string);
	}
325662
public function toCamelCase(string $string): string
    {
        $words = \str_replace(['-', '_'], ' ', $string);

        $words = \str_replace(' ', '', \ucwords($words));

        return \lcfirst($words);
    }
658733
private static String capitalise(String s) {
    if(s.length()==0){return s;}

  StringBuilder s1=new StringBuilder(s);
  if (Character.isLowerCase(s1.charAt(0))){
    s1.setCharAt(0,Character.toUpperCase(s1.charAt(0)));
  }	
  for(int j=1;j<s1.length();j++){
    if(Character.isUpperCase(s1.charAt(j))){
      s1.setCharAt(j,Character.toLowerCase(s1.charAt(j)));
    }
  }
  return s1.toString();
  }
1179603
public static function titleCase($string) {
        return static::cache(array(__METHOD__, $string), function() use ($string) {
            return mb_convert_case(str_replace('_', ' ', $string), MB_CASE_TITLE);
        });
    }
532062
protected function normalizeString($string)
    {
        $value = $this->isAllUpperCase($string) ?
            strtolower(trim($string, '_-#$%')) :
            Str::snakeCase(trim($string, '_-#$%'));

        return strtolower(preg_replace('/[^a-zA-Z0-9(^@)]+/', '-', $value));
    }
182418
static String capitalizeFirstWordAsciiOnly(String s) {
    if (s == null || s.isEmpty()) {
      return s;
    }
    int secondWordStart = s.length();
    for (int i = 1; i < s.length(); i++) {
      if (!isLowerCaseAsciiOnly(s.charAt(i))) {
        secondWordStart = i;
        break;
      }
    }
    return toUpperCaseAsciiOnly(s.substring(0, secondWordStart)) + s.substring(secondWordStart);
  }
76881
public String capitalize(String string) {
		if (string == null || string.length() < 1) {
			return "";
		}
		return string.substring(0, 1).toUpperCase() + string.substring(1);
	}
691218
public static String capitalize(String s) {
		if (s == null || isEmpty(s)) {
			return s;
		}
		return (new StringBuilder(s.length())).append(Character.toTitleCase(s.charAt(0))).append(s.substring(1)).toString();
	}
335810
public function nlToPbr($string)
	{
		$string = trim($string);
		$string = Modifiers::linebreaks($string);
		$string = str_replace("\n", '<br />', $string);
		$string = str_replace('<br /><br />', "</p>\n<p>", $string);
		$string = str_replace('<p></p>', '', $string);
		return '<p>' . $string . '</p>' . PHP_EOL;
	}
310674
public function toPascalCase(string $string): string
    {
        $string = Transliterator::urlize((string)$string);
        $string = str_replace('-', '', ucwords($string, '-'));

        return $string;
    }
593340
public static function camelCase($string) {
        return static::cache(array(__METHOD__, $string), function() use ($string) {
            return str_replace(' ', '', mb_convert_case(str_replace(array('_', '-'), ' ', preg_replace('/[^-_a-z0-9\s]+/i', '', $string)), MB_CASE_TITLE));
        });
    }
606991
public static function uppercase($string = false, $selector = false) {

        if ($string) {

            switch ($selector) {
                case 'first':
                    return ucfirst($string);
                case 'words':
                    return ucwords($string);
                default:
                    return strtoupper($string);
            }
        }

        return false;
    }
802328
public static function toPascalCase(string $string): string
    {
        $words = self::_prepStringForCasing($string);
        $string = implode('', array_map([
            static::class,
            'upperCaseFirst'
        ], $words));

        return $string;
    }
1009449
public static String capitalizeWord( String s )
	{
		// validate
		if( (s == null) || (s.length() == 0) )
		{
			return s;
		}
		return s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase();
	}