2010-04-03 10:39:32 -04:00
|
|
|
# Regular expression literals.
|
2010-02-27 14:30:14 -05:00
|
|
|
ok 'x'.match(/x/g)
|
|
|
|
ok 'x'.match /x/g
|
|
|
|
ok 'x'.match(/x/)
|
|
|
|
ok 'x'.match /x/
|
|
|
|
|
|
|
|
ok 4 / 2 / 1 is 2
|
|
|
|
|
2010-07-25 01:23:37 -04:00
|
|
|
y = 4
|
|
|
|
x = 2
|
|
|
|
g = 1
|
2010-02-27 14:30:14 -05:00
|
|
|
|
2010-03-08 22:25:06 -05:00
|
|
|
ok y / x/g is 2
|
|
|
|
|
2010-10-04 08:50:50 -04:00
|
|
|
ok /:\/[/]goog/.test 'http://google.com'
|
2010-05-14 09:14:41 -04:00
|
|
|
|
2010-07-25 01:23:37 -04:00
|
|
|
obj = {
|
2010-05-14 09:14:41 -04:00
|
|
|
width: -> 10
|
|
|
|
height: -> 20
|
|
|
|
}
|
2010-07-25 01:23:37 -04:00
|
|
|
id = 2
|
2010-05-14 09:14:41 -04:00
|
|
|
|
|
|
|
ok (obj.width()/id - obj.height()/id) is -5
|
2010-10-03 19:22:42 -04:00
|
|
|
|
2010-10-11 20:35:59 -04:00
|
|
|
eq /\\/.source, "\\\\"
|
|
|
|
|
|
|
|
|
2010-10-03 22:55:49 -04:00
|
|
|
eq /^I'm\s+Heregex?\/\/\//gim + '', ///
|
|
|
|
^ I'm \s+ Heregex? / // # or not
|
2010-10-03 19:22:42 -04:00
|
|
|
///gim + ''
|
2010-10-04 14:30:48 -04:00
|
|
|
eq '\\\\#{}\\\\\\\"', ///
|
2010-10-03 19:22:42 -04:00
|
|
|
#{
|
2010-10-04 08:50:50 -04:00
|
|
|
"#{ '\\' }" # normal comment
|
2010-10-03 19:22:42 -04:00
|
|
|
}
|
2010-10-04 08:50:50 -04:00
|
|
|
# regex comment
|
2010-10-03 19:22:42 -04:00
|
|
|
\#{}
|
2010-10-04 14:30:48 -04:00
|
|
|
\\ \"
|
2010-10-03 19:22:42 -04:00
|
|
|
///.source
|
2010-10-03 22:55:49 -04:00
|
|
|
eq /// /// + '', '/(?:)/'
|
2010-10-05 00:16:55 -04:00
|
|
|
|
|
|
|
|
|
|
|
# Issue #584.
|
|
|
|
regex = /[/]/
|
|
|
|
s1 = "Hello there"
|
|
|
|
s2 = "Hello / there"
|
|
|
|
ok not regex.test(s1)
|
2010-10-11 20:35:59 -04:00
|
|
|
ok regex.test(s2)
|