# Regex w/ String Interpolation

**URL:** <https://discourse.julialang.org/t/regex-w-string-interpolation/3545>\
**Category:** General Usage\
**Tags:** question, regex, string-interpolation\
**Created:** [May 5, 2017, 9:10pm UTC](https://discourse.julialang.org/t/regex-w-string-interpolation/3545 "2017-05-05T21:10:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![djsegal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/djsegal/32/13752_2.png) [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Post date:** [May 5, 2017, 9:10pm UTC](https://discourse.julialang.org/t/regex-w-string-interpolation/3545/1 "2017-05-05T21:10:06Z")

</div>

I want to do something along the lines of:

```julia
a = "focus"
ismatch(r"$(a)\s*:\s*true", "# focus: true")

```

But this doesnt work // probably similar to [issue #1797](https://github.com/JuliaLang/julia/issues/1797)

* * *

What is the correct way to do this?

`eval( parse( "ismatch(r\"$(a)\\s*:\\s*true\", \"# focus: true\")" ) )`

feels super dirty

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [May 5, 2017, 9:13pm UTC](https://discourse.julialang.org/t/regex-w-string-interpolation/3545/2 "2017-05-05T21:13:53Z")

</div>

```julia
a = "focus"
r = Regex("$(a)\\s*:\\s*true")
ismatch(r, "# focus: true")

```
