Library reference

Remove spaces at both ends

Remove the spaces before and after a name. A space between two words stays in place. These examples use ordinary spaces.

strip

Simple example

Trim the single letter.

Start' a '
Resulta
lesson.jl
function main()
    println(strip(" a "))
end

main()
Output
a
Advertisements

Everyday examples

Remove the extra spaces copied around a ticket number.

Start' B12 '
ResultB12
lesson.jl
function main()
    println(strip("  B12 "))
end

main()
Output
B12

Clean up the outside spaces on a shelf label.

Start' Red Apples '
ResultRed Apples
lesson.jl
function main()
    println(strip(" Red Apples  "))
end

main()
Output
Red Apples

Clean up a name copied from a signup sheet.

Start' Ana '
ResultAna
lesson.jl
function main()
    println(strip("  Ana "))
end

main()
Output
Ana
Run the example
Terminal
julia lesson.jl
Official documentation