Extracting numbers from Symbols

Given a vector of Symbols like [:v01, :v20, :v33], is there a way to extract the numbers directly without first converting them to strings? My current solution with string conversion is:

v = [:v01, :v20, :v33]
nums = @. parse(Int,filter(isdigit,string(v)))

No, I don’t think there is another way.

For performance considerations, you probably should rethink using Symbols if you need more information contained in your objects. Why not use a struct?

1 Like

Ah okay. I just wanted to confirm I wasn’t missing something. For my use case it makes sense to use a dataframe (as opposed to a matrix), so I’ll probably import/convert the data and use the symbol vector to extract the correct columns.

Thanks for the quick reply!