$string = 'LannistersAlwaysPayTheirDebts';
$underscored = Strings::camelCaseToUnderscore($string);
Result:
lannisters_always_pay_their_debts
public static camelCaseToUnderscore ( string $string ) : string | ||
$string | string | |
리턴 | string |
public static function camelCaseToUnderscore($string)
{
return mb_strtolower(preg_replace('/([[:lower:]])([[:upper:]])/u', '$1_$2', $string));
}
public function parse() { if (preg_match('/^findBy([a-zA-Z]\\w*)$/', $this->method, $names)) { $names = explode('And', $names[1]); $this->names = Arrays::map($names, function ($name) { return Strings::camelCaseToUnderscore($name); }); } }