2010-04-03 10:39:32 -04:00
|
|
|
# Interpolate regular expressions.
|
2010-07-24 22:23:37 -07:00
|
|
|
name = 'Moe'
|
2010-03-08 20:05:02 +02:00
|
|
|
|
2010-07-26 23:31:55 -04:00
|
|
|
ok not not '"Moe"'.match(/^"#{name}"$/i)
|
|
|
|
ok '"Moe!"'.match(/^"#{name}"$/i) is null
|
2010-03-08 20:05:02 +02:00
|
|
|
|
2010-07-26 23:31:55 -04:00
|
|
|
ok not not 'Moe'.match(/^#name$/)
|
|
|
|
ok 'Moe!'.match(/^#name/)
|
2010-03-08 20:05:02 +02:00
|
|
|
|
2010-07-26 23:31:55 -04:00
|
|
|
ok 'Moe!'.match(/#{"#{"#{"#name"}"}"}/imgy)
|
2010-03-08 20:05:02 +02:00
|
|
|
|
|
|
|
ok '$a$b$c'.match(/\$A\$B\$C/i)
|
|
|
|
|
2010-07-24 22:23:37 -07:00
|
|
|
a = 1
|
|
|
|
b = 2
|
|
|
|
c = 3
|
2010-07-26 23:31:55 -04:00
|
|
|
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+/]
|
2010-07-26 23:31:55 -04:00
|
|
|
ok (/#a#b#c$/i).toString() is '/12/\\d+/$/i'
|