RegExp_lastParen.js (2267B)
1 /* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 7 /** 8 Filename: RegExp_lastParen.js 9 Description: 'Tests RegExps lastParen property' 10 11 Author: Nick Lerissa 12 Date: March 12, 1998 13 */ 14 15 var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; 16 var TITLE = 'RegExp: lastParen'; 17 18 writeHeaderToLog('Executing script: RegExp_lastParen.js'); 19 writeHeaderToLog( SECTION + " "+ TITLE); 20 21 // 'abcd'.match(/(abc)d/); RegExp.lastParen 22 'abcd'.match(/(abc)d/); 23 new TestCase ( "'abcd'.match(/(abc)d/); RegExp.lastParen", 24 'abc', RegExp.lastParen); 25 26 // 'abcd'.match(new RegExp('(abc)d')); RegExp.lastParen 27 'abcd'.match(new RegExp('(abc)d')); 28 new TestCase ( "'abcd'.match(new RegExp('(abc)d')); RegExp.lastParen", 29 'abc', RegExp.lastParen); 30 31 // 'abcd'.match(/(bcd)e/); RegExp.lastParen 32 'abcd'.match(/(bcd)e/); 33 new TestCase ( "'abcd'.match(/(bcd)e/); RegExp.lastParen", 34 'abc', RegExp.lastParen); 35 36 // 'abcdefg'.match(/(a(b(c(d)e)f)g)/); RegExp.lastParen 37 'abcdefg'.match(/(a(b(c(d)e)f)g)/); 38 new TestCase ( "'abcdefg'.match(/(a(b(c(d)e)f)g)/); RegExp.lastParen", 39 'd', RegExp.lastParen); 40 41 // 'abcdefg'.match(/(a(b)c)(d(e)f)/); RegExp.lastParen 42 'abcdefg'.match(/(a(b)c)(d(e)f)/); 43 new TestCase ( "'abcdefg'.match(/(a(b)c)(d(e)f)/); RegExp.lastParen", 44 'e', RegExp.lastParen); 45 46 // 'abcdefg'.match(/(^)abc/); RegExp.lastParen 47 'abcdefg'.match(/(^)abc/); 48 new TestCase ( "'abcdefg'.match(/(^)abc/); RegExp.lastParen", 49 '', RegExp.lastParen); 50 51 // 'abcdefg'.match(/(^a)bc/); RegExp.lastParen 52 'abcdefg'.match(/(^a)bc/); 53 new TestCase ( "'abcdefg'.match(/(^a)bc/); RegExp.lastParen", 54 'a', RegExp.lastParen); 55 56 // 'abcdefg'.match(new RegExp('(^a)bc')); RegExp.lastParen 57 'abcdefg'.match(new RegExp('(^a)bc')); 58 new TestCase ( "'abcdefg'.match(new RegExp('(^a)bc')); RegExp.lastParen", 59 'a', RegExp.lastParen); 60 61 // 'abcdefg'.match(/bc/); RegExp.lastParen 62 'abcdefg'.match(/bc/); 63 new TestCase ( "'abcdefg'.match(/bc/); RegExp.lastParen", 64 '', RegExp.lastParen); 65 66 test();