1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00
jashkenas--coffeescript/test/test_regexp_interpolation.coffee

21 lines
388 B
CoffeeScript
Raw Normal View History

# Interpolate regular expressions.
2010-07-24 22:23:37 -07:00
name = 'Moe'
ok not not '"Moe"'.match(/^"#{name}"$/i)
ok '"Moe!"'.match(/^"#{name}"$/i) is null
ok not not 'Moe'.match(/^#name$/)
ok 'Moe!'.match(/^#name/)
ok 'Moe!'.match(/#{"#{"#{"#name"}"}"}/imgy)
ok '$a$b$c'.match(/\$A\$B\$C/i)
2010-07-24 22:23:37 -07:00
a = 1
b = 2
c = 3
ok '123'.match(/#a#b#c/i)
2010-03-08 21:55:06 -05:00
2010-07-24 22:23:37 -07:00
[a, b, c] = [1, 2, /\d+/]
ok (/#a#b#c$/i).toString() is '/12/\\d+/$/i'