Regex w/ String Interpolation

I want to do something along the lines of:

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

But this doesnt work // probably similar to issue #1797


What is the correct way to do this?

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

feels super dirty

3 Likes
a = "focus"
r = Regex("$(a)\\s*:\\s*true")
ismatch(r, "# focus: true")
9 Likes