Is there a function in the native library to pad a string with ~equal spaces on both sides?
cpad("woof", 8)
would yield:
" woof "
Is there a function in the native library to pad a string with ~equal spaces on both sides?
cpad("woof", 8)
would yield:
" woof "
Apparently there is in base somewhere.
I just don’t know how to access it…
julia> Base.cpad("March", 10)
" March "
Seems like there’s a whole host of string manipulation functions that could be moved out into a package.
Also, cpad
doesn’t work on symbols (like lpad
and rpad
do)
Base.cpad(s::Symbol, i::Integer) = Base.cpad(string(s), i)
Seems like cpad
could be exported if lpad
and rpad
are.
I wonder if this is another case where there should just be a single pad
function that all of these can be rolled into?
Created a github issue to help resolve this: