Working with Strings
Regex
You can also use regular expressions. They are very useful to parse text files.
line = ">sp|O43521|B2L11_HUMAN Bcl-2-like protein 11 OS=Homo sapiens OX=9606 GN=BCL2L11 PE=1 SV=1"
">sp|O43521|B2L11_HUMAN Bcl-2-like protein 11 OS=Homo sapiens OX=9606 GN=BCL2L11 PE=1 SV=1"
regex = r"^>\w+\|(\w+)\|"
r"^>\w+\|(\w+)\|"
m = match(regex, line)
RegexMatch(">sp|O43521|", 1="O43521")
if m !== nothing
println(m[1])
end
O43521
String interpolation
You can interpolate values, single variables or the result of more complex expressions, into strings using $
:
a = 1
b = 2
"$a + $b is $(a + b)"
"1 + 2 is 3"
This page was generated using Literate.jl.