|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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_lastMatch.js |
|
9 Description: 'Tests RegExps lastMatch 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 VERSION = 'no version'; |
|
17 startTest(); |
|
18 var TITLE = 'RegExp: lastMatch'; |
|
19 |
|
20 writeHeaderToLog('Executing script: RegExp_lastMatch.js'); |
|
21 writeHeaderToLog( SECTION + " "+ TITLE); |
|
22 |
|
23 |
|
24 // 'foo'.match(/foo/); RegExp.lastMatch |
|
25 'foo'.match(/foo/); |
|
26 new TestCase ( SECTION, "'foo'.match(/foo/); RegExp.lastMatch", |
|
27 'foo', RegExp.lastMatch); |
|
28 |
|
29 // 'foo'.match(new RegExp('foo')); RegExp.lastMatch |
|
30 'foo'.match(new RegExp('foo')); |
|
31 new TestCase ( SECTION, "'foo'.match(new RegExp('foo')); RegExp.lastMatch", |
|
32 'foo', RegExp.lastMatch); |
|
33 |
|
34 // 'xxx'.match(/bar/); RegExp.lastMatch |
|
35 'xxx'.match(/bar/); |
|
36 new TestCase ( SECTION, "'xxx'.match(/bar/); RegExp.lastMatch", |
|
37 'foo', RegExp.lastMatch); |
|
38 |
|
39 // 'xxx'.match(/$/); RegExp.lastMatch |
|
40 'xxx'.match(/$/); |
|
41 new TestCase ( SECTION, "'xxx'.match(/$/); RegExp.lastMatch", |
|
42 '', RegExp.lastMatch); |
|
43 |
|
44 // 'abcdefg'.match(/^..(cd)[a-z]+/); RegExp.lastMatch |
|
45 'abcdefg'.match(/^..(cd)[a-z]+/); |
|
46 new TestCase ( SECTION, "'abcdefg'.match(/^..(cd)[a-z]+/); RegExp.lastMatch", |
|
47 'abcdefg', RegExp.lastMatch); |
|
48 |
|
49 // 'abcdefgabcdefg'.match(/(a(b(c(d)e)f)g)\1/); RegExp.lastMatch |
|
50 'abcdefgabcdefg'.match(/(a(b(c(d)e)f)g)\1/); |
|
51 new TestCase ( SECTION, "'abcdefgabcdefg'.match(/(a(b(c(d)e)f)g)\\1/); RegExp.lastMatch", |
|
52 'abcdefgabcdefg', RegExp.lastMatch); |
|
53 |
|
54 test(); |