str-replace()
문자 값의 일부를 다른 문자 값으로 대체하는 유틸리티 함수
용도
사용법
@debug str-replace("string replace", " ", "-"); // "string-replace" 반환
@debug str-replace("top Left", " "); // "topLeft" 반환로직
@function str-replace($string, $search, $replace: '') {
$index: str-index($string, $search);
@if $index {
@return str-slice($string, 1, $index - 1) + $replace +
str-replace(
str-slice($string, $index + str-length($search)),
$search,
$replace
);
}
@return $string;
}참고
Last updated