# Extract variables from strings

**URL:** https://discourse.julialang.org/t/extract-variables-from-strings/72881
**Category:** General Usage
**Tags:** macros, strings
**Created:** [December 10, 2021, 8:02am UTC](https://discourse.julialang.org/t/extract-variables-from-strings/72881 "2021-12-10T08:02:45Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![Bardo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bardo/32/21601_2.png) [@Bardo](https://discourse.julialang.org/u/Bardo)
#### Post date: [December 10, 2021, 9:37am UTC](https://discourse.julialang.org/t/extract-variables-from-strings/72881/2 "2021-12-10T09:37:44Z")

</div>

Possibly related: [Parse structured string to dictionary - General Usage - JuliaLang](https://discourse.julialang.org/t/parse-structured-string-to-dictionary/8126)

A simple

```julia
_, x, _, y = split("test var_1 and var_2")

```

sets x and y as desired.  
It was not clear from your description if variable names x and y are hard-wired or to be parsed first.  
But using `$x` in a string does interpolation and requires x to be known.

---

_[View the full topic](https://discourse.julialang.org/t/extract-variables-from-strings/72881)._
