안녕하세요! tom 입니다.
오늘은 문자에 패딩을 넣어보겠습니다.
예를 들면
“456” => “456000”
애플 문서를 보면
Declaration
func padding(toLength newLength: Int,
withPad padString: String,
startingAt padIndex: Int) -> String
Parameters
newLength
The new length for the receiver.
padString
The string with which to extend the receiver.
padIndex
The index in padString
from which to start padding.
Return Value
A new string formed from the receiver by either removing characters from the end, or by appending as many occurrences of padString
as necessary.
사용법은 간단하다(만약 6자리를 넘어가면 잘라주기도 한다.)
그럼 “456” => “000456” 이렇게는 어떻게 해야할까?
그럼이만…