This page provides syntax for strings and characters in Julia as well as some of their associated functions. Each section includes an example to demonstrate the described syntax or function.
Char
is a single character
String
is a sequence of one or more characters (index values start at 1
)
Action | Function |
---|---|
Use typeof()
function to determine type
Input:
Output:
Julia Documentation: Manual - Strings
Julia Documentation: Base - Strings
Think Julia: Chapter 8 - Strings
get word
length
length(word)
extract nth
character from word
word[n]
extract substring nth-mth
character from word
word[n:m]
search for letter
in word
findfirst(isequal(letter), word)
search for subword
in word
occursin(word, subword)
remove record separator from word
(e.g., n
)
chomp(word)
remove last character from word
chop(word)