String Operations
Basic operations
Module
UTCGP.str_basic — Module
Some basic operations.
Exports :
- bundle_string_basic :
number_to_string
Functions
UTCGP.str_basic.number_to_string — Function
number_to_string(num::Number, args...)Returns the number as a string.
julia> number_to_string(121)
"121"julia> number_to_string(121.12)
"121.12"Grep Module
Module
UTCGP.str_grep — Module
Grep Operations
Exports :
- bundle_string_grep :
replace_patternreplace\_first\_patternremove_pattern
Functions
UTCGP.str_grep.replace_pattern — Function
Replaces a pattern from by another string to in the strign s.
julia> replace_pattern("HelloHello", "Hello", "hello")
"hellohello"Also can remove a char :
julia> replace_pattern("Camel_case", "_", "")
"Camelcase"UTCGP.str_grep.replace_first_pattern — Function
Replaces a pattern from by another string to in the strign s only 1 time.
julia> replace_first_pattern("HelloHello", "Hello", "hello")
"helloHello"julia> replace_first_pattern("CCDC", "C", "A")
"ACDC"UTCGP.str_grep.remove_pattern — Function
Removes the pattern from the strign s.
julia> remove_pattern("HelloHello", "Hello")
""Paste
Module
UTCGP.str_paste — Module
Paste Operations
Exports :
- bundle_string_paste :
pastepaste_0paste_with_space
- bundle_string_concat_list_string :
paste_space_list_stringpaste_list_string_seppaste_list_string
Paste Strings
UTCGP.str_paste.paste — Function
Concatenates s1 and s2 with sep in the middle
julia> paste("kebab", "case", "-")
"kebab-case"UTCGP.str_paste.paste0 — Function
Concatenates s1 and s2.
julia> paste0("ju", "lia")
"julia"UTCGP.str_paste.paste_with_space — Function
Concatenates s1 and s2 with an space in the middle.
julia> paste_with_space("ju", "lia")
"ju lia"Paste List Strings
UTCGP.str_paste.paste_space_list_string — Function
Joins strings in a list with an space in the middle.
julia> paste_space_list_string(["kebab", "case"])
"kebab case"UTCGP.str_paste.paste_list_string_sep — Function
Joins strings in a list with a given delim in the middle.
julia> paste_list_string_sep(["kebab", "case"], "-")
"kebab-case"UTCGP.str_paste.paste_list_string — Function
Joins strings in a list with no delimeter.
julia> paste_list_string(["kebab", "case"])
"kebabcase"Conditional
UTCGP.str_conditional — Module
Conditional Operations
Exports :
- bundle_string_conditional :
if_stringif_not_stringif_else_stringlongest_stringshortest_string
For if_string, if_not_string and if_else_string, the cond parameter is trunced to Int.
UTCGP.str_conditional.if_string — Function
if_string(s::String, cond::Number, args...)::StringReturns the string s if the cond is different than 0. Else an empty string is returned.
cond is a Number, it is trunc to Int before comparison with 0.
julia> if_string("julia", 0)
""julia> if_string("julia", 137287.2)
"julia"UTCGP.str_conditional.if_not_string — Function
if_not_string(s::String, cond::Number, args...)::StringThis functions is the inverse of if_string.
Returns the string s if the cond is equal to 0. Else an empty string is returned. cond is a Number, it is trunc to Int before comparison with 0.
julia> if_not_string("julia", 0)
"julia"julia> if_not_string("julia", 137287.2)
""UTCGP.str_conditional.if_else_string — Function
if_else_string(s1::String, s2::String, cond::Number, args...)::StringReturns the string s1 if the cond is different than 0. Else s2 is returned. cond is a Number, it is trunc to Int before comparison with 0.
julia> if_else_string("julia", "R" , 0)
"R"julia> if_else_string("julia", "R" ,137287.2)
"julia"UTCGP.str_conditional.longest_string — Function
longest_string(s1::String, s2::String, args...)::StringReturns the longest string between s1 and s2. If the length is the same, it returns s1.
julia> longest_string("julia", "R")
"julia"julia> longest_string("julia", "jjjjj")
"julia"UTCGP.str_conditional.shortest_string — Function
shortest_string(s1::String, s2::String, args...)::StringReturns the shortest string between s1 and s2. If the length is the same, it returns s1.
julia> shortest_string("julia", "R")
"R"julia> shortest_string("julia", "jjjjj")
"julia"Lower, Upper, Capitalize
Module
UTCGP.str_caps — Module
Lower Upper and Capitalize functions
Exports :
- bundle_string_caps :
uppercase_uppercase_atuppercase_afteruppercase_char_afteruppercase_beforeuppercase_char_beforelowercase_lowercase_atlowercase_afterlowercase_char_afterlowercase_beforelowercase_char_beforecapitalize_firstcapitalize_all
Upper Case
UTCGP.str_caps.uppercase_ — Function
uppercase_(s::String, args...)Uppercases s
julia> uppercase_("julia")
"JULIA"UTCGP.str_caps.uppercase_at — Function
uppercase_at(s::String, at::Number, args...)Uppercases s at a given index at.
The index is clipped between 1 (the first index) and the length of s (the last index).
# It can capitalize
julia> uppercase_at("julia",1)
"Julia"# index is clipped
julia> uppercase_at("julia",-100)
"Julia"UTCGP.str_caps.uppercase_after — Function
uppercase_after(s::String, after::String, args...)Uppercases everything that comes after a match.
If after is empty, it returns the string s.
julia> uppercase_after("julia","ju")
"juLIA"UTCGP.str_caps.uppercase_char_after — Function
uppercase_char_after(s::String, after::String, args...)Uppercases one character that comes after a match. It does that for every match.
If after is empty, it returns the string s.
julia> uppercase_char_after("julia","ju")
"juLia"# it works on every match
julia> uppercase_char_after("julia julia","ju")
"juLia juLia"UTCGP.str_caps.uppercase_before — Function
uppercase_before(s::String, before::String, args...)Uppercases everything that comes before a match.
If before is empty, it returns the string s.
julia> uppercase_before("julia","lia")
"JUlia"UTCGP.str_caps.uppercase_char_before — Function
uppercase_char_before(s::String, before::String, args...)Uppercases one character that comes before a match. It does that for every match.
If before is empty, it returns the string s.
julia> uppercase_char_before("julia","lia")
"jUlia"# it works on every match
julia> uppercase_char_before("julia julia","lia")
"jUlia jUlia"Lower Case
UTCGP.str_caps.lowercase_ — Function
lowercase_(s::String, args...)Lowercases s
julia> lowercase_("JULIA")
"julia"UTCGP.str_caps.lowercase_at — Function
lowercase_at(s::String, at::Number, args...)Lowercases s at a given index at.
The index is clipped between 1 (the first index) and the length of s (the last index).
julia> lowercase_at("JULIA",1)
"jULIA"# index is clipped
julia> lowercase_at("JULIA",100)
"JULIa"UTCGP.str_caps.lowercase_after — Function
lowercase_after(s::String, after::String, args...)Lowercases everything that comes after a match.
If after is empty, it returns the string s.
julia> lowercase_after("juLIA","ju")
"julia"UTCGP.str_caps.lowercase_char_after — Function
lowercase_char_after(s::String, after::String, args...)Lowercases one character that comes after a match. It does that for every match.
If after is empty, it returns the string s.
julia> lowercase_char_after("JULIA","JU")
"JUlIA"# it works on every match
julia> lowercase_char_after("JULIA JULIA","JU")
"JUlIA JUlIA"UTCGP.str_caps.lowercase_before — Function
lowercase_before(s::String, before::String, args...)Lowercases everything that comes before a match.
If before is empty, it returns the string s.
julia> lowercase_before("JULIA","LIA")
"juLIA"UTCGP.str_caps.lowercase_char_before — Function
lowercase_char_before(s::String, before::String, args...)Lowercases one character that comes before a match. It does that for every match.
If before is empty, it returns the string s.
julia> lowercase_char_before("JUlia","lia")
"Julia"# it works on every match
julia> lowercase_char_before("JULIA JULIA","LIA")
"JuLIA JuLIA"Capitalize
UTCGP.str_caps.capitalize_first — Function
capitalize_first(s::String, args...)::StringApplies the Base.uppercasefirst function.
julia> capitalize_first("julia julia")
"Julia julia"UTCGP.str_caps.capitalize_all — Function
capitalize_all(s::String, args...)::StringApplies the Base.titlecase function.
julia> capitalize_all("julia julia")
"Julia Julia"# The titlecase functions takes all non letters as separators
julia> capitalize_all("julia-julia")
"Julia-Julia"