Coffeescript supports strings interpolation:
user = "world"
greeting = "Hello #{user}!"
Is it possible to use interpolation in regex just like in strings? E.g.
regex = /Hello #{user}/g
P.S. I know that I can use RegExp(greeting, 'g')
, I just want a bit cleaner code.
Block Regular Expressions (Heregexes) support interpolation.
This coffeescript code:
compiles to