# Extracting numbers from Symbols

**URL:** <https://discourse.julialang.org/t/extracting-numbers-from-symbols/113930>\
**Category:** General Usage\
**Tags:** question\
**Created:** [May 7, 2024, 3:43am UTC](https://discourse.julialang.org/t/extracting-numbers-from-symbols/113930 "2024-05-07T03:43:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![RobertGregg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/robertgregg/32/22105_2.png) [@RobertGregg](https://discourse.julialang.org/u/RobertGregg)\
**Post date:** [May 7, 2024, 3:43am UTC](https://discourse.julialang.org/t/extracting-numbers-from-symbols/113930/1 "2024-05-07T03:43:10Z")

</div>

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:

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

```

---

<div class="post-metadata">

**Author:** ![abraemer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abraemer/32/51403_2.png) [@abraemer](https://discourse.julialang.org/u/abraemer)\
**Post date:** [May 7, 2024, 3:49am UTC](https://discourse.julialang.org/t/extracting-numbers-from-symbols/113930/2 "2024-05-07T03:49:30Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![RobertGregg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/robertgregg/32/22105_2.png) [@RobertGregg](https://discourse.julialang.org/u/RobertGregg)\
**Post date:** [May 7, 2024, 4:03am UTC](https://discourse.julialang.org/t/extracting-numbers-from-symbols/113930/3 "2024-05-07T04:03:20Z")

</div>

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!
