// Gets substring from string // ------------------------------------------------------------------------------- // @dependence `string-to-list()` // ------------------------------------------------------------------------------- // @param $full-string [String] : string that contains substring // @param $depth [Integer | "last | "first"] : depth of substring // ------------------------------------------------------------------------------- // @return [String] @function get-substring($full-string, $depth) { @if is-string($full-string) { $get-substring: string-to-list($full-string); @if $depth == "last" { @return nth($get-substring, length($get-substring)); } @else if $depth == "first" { @return nth($get-substring, 1); } @else { @return nth($get-substring, $depth); } } @else { @return "You did not input a valid string: #{$full-string}"; } }