A string is a finite sequence of one or more characters, enclosed in double-quotes. An example of a string is:
“here is a string between double quotes”
The important things to note about strings are:
greeting = "Hello I am a Julia string"
intro = greeting
println(intro)
Hello I am a Julia string
In Julia, elements of a string can be extracted to form multiple substrings using the square bracket.
string1 = "extract me"
element = string1[1:3]
println(element)
ex
Strings can also be interpolated in Julia. Interpolation is the process of executing whatever is executable in a string. In Julia, a dollar sign ($
) is used to insert the value of a variable in the string.
name = "John"
age = 47
println("Hello $name, your age is $age")
Hello John, your age is 47
The built-in concrete type used for strings and string literals in Julia is String. This supports a full range of Unicode characters via the UTF-8 encoding.