| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
gTestfile = 'everything.js'; |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; |
| 17 |
var VERSION = 'no version'; |
| 18 |
startTest(); |
| 19 |
var TITLE = 'RegExp'; |
| 20 |
|
| 21 |
writeHeaderToLog('Executing script: everything.js'); |
| 22 |
writeHeaderToLog( SECTION + " "+ TITLE); |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
new TestCase ( SECTION, "'Sally and Fred are sure to come'.match(/^[a-z\\s]*/i)", |
| 27 |
String(["Sally and Fred are sure to come"]), String('Sally and Fred are sure to come'.match(/^[a-z\s]*/i))); |
| 28 |
|
| 29 |
|
| 30 |
new TestCase ( SECTION, "'test123W+xyz'.match(new RegExp('^[a-z]*[0-9]+[A-Z]?.(123|xyz)$'))", |
| 31 |
String(["test123W+xyz","xyz"]), String('test123W+xyz'.match(new RegExp('^[a-z]*[0-9]+[A-Z]?.(123|xyz)$')))); |
| 32 |
|
| 33 |
|
| 34 |
new TestCase ( SECTION, "'number one 12365 number two 9898'.match(/(\d+)\D+(\d+)/)", |
| 35 |
String(["12365 number two 9898","12365","9898"]), String('number one 12365 number two 9898'.match(/(\d+)\D+(\d+)/))); |
| 36 |
|
| 37 |
var simpleSentence = /(\s?[^\!\?\.]+[\!\?\.])+/; |
| 38 |
|
| 39 |
new TestCase ( SECTION, "'See Spot run.'.match(simpleSentence)", |
| 40 |
String(["See Spot run.","See Spot run."]), String('See Spot run.'.match(simpleSentence))); |
| 41 |
|
| 42 |
|
| 43 |
new TestCase ( SECTION, "'I like it. What's up? I said NO!'.match(simpleSentence)", |
| 44 |
String(["I like it. What's up? I said NO!",' I said NO!']), String('I like it. What\'s up? I said NO!'.match(simpleSentence))); |
| 45 |
|
| 46 |
|
| 47 |
new TestCase ( SECTION, "'the quick brown fox jumped over the lazy dogs'.match(/((\\w+)\\s*)+/)", |
| 48 |
String(['the quick brown fox jumped over the lazy dogs','dogs','dogs']),String('the quick brown fox jumped over the lazy dogs'.match(/((\w+)\s*)+/))); |
| 49 |
|
| 50 |
test(); |