Hi!
Within the program I have coded, I arrived at a place where I have the following Expr
:
ex = :(Float64[32])
Is there any way to extract the number within brackets without doing
ex_str = String(Symbol(ex))
num = match(r"\[\d*\]",ex_str)
?
Thanks!
julia> ex = :(Float64[32])
:(Float64[32])
julia> number = ex.args[2]
32
Great, thanks!!
I had tried to inspect the expression with fieldnames(ex)
, but forgot that it should have been fieldnames(Expr)
!
jules
4
Also always helpful:
julia> :(Float64[32]) |> dump
Expr
head: Symbol ref
args: Array{Any}((2,))
1: Symbol Float64
2: Int64 32
1 Like