Skip to content

OmniTools.ForString

Exported

OmniTools.ForString.to_uppercase_first Function
julia
to_uppercase_first(s::AbstractString, prefix="")

Converts the first letter of each word in a string to uppercase, removes underscores, and adds a prefix.

Arguments:

  • s: The input string.

  • prefix: A prefix to add to the resulting string (default: "").

Returns:

A Symbol with the transformed string.

Examples

julia
julia> using OmniTools

julia> to_uppercase_first("hello_world", "Time")
:TimeHelloWorld
Code
julia
function to_uppercase_first(str::AbstractString, prefix::AbstractString="")
    str_s = Base.String(str)
    prefix_s = Base.String(prefix)
    return Symbol(prefix_s * join(uppercasefirst.(split(str_s, "_"))))
end

Internal

OmniTools.jl - Foundational utilities for Julia development