| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
gTestfile = 'string_replace.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 = 'String: replace'; |
| 20 |
|
| 21 |
writeHeaderToLog('Executing script: string_replace.js'); |
| 22 |
writeHeaderToLog( SECTION + " "+ TITLE); |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
new TestCase ( SECTION, "'adddb'.replace(/ddd/,'XX')", |
| 27 |
"aXXb", 'adddb'.replace(/ddd/,'XX')); |
| 28 |
|
| 29 |
|
| 30 |
new TestCase ( SECTION, "'adddb'.replace(/eee/,'XX')", |
| 31 |
'adddb', 'adddb'.replace(/eee/,'XX')); |
| 32 |
|
| 33 |
|
| 34 |
new TestCase ( SECTION, "'34 56 78b 12'.replace(new RegExp('[0-9]+b'),'**')", |
| 35 |
"34 56 ** 12", '34 56 78b 12'.replace(new RegExp('[0-9]+b'),'**')); |
| 36 |
|
| 37 |
|
| 38 |
new TestCase ( SECTION, "'34 56 78b 12'.replace(new RegExp('[0-9]+c'),'XX')", |
| 39 |
"34 56 78b 12", '34 56 78b 12'.replace(new RegExp('[0-9]+c'),'XX')); |
| 40 |
|
| 41 |
|
| 42 |
new TestCase ( SECTION, "'original'.replace(new RegExp(),'XX')", |
| 43 |
"XXoriginal", 'original'.replace(new RegExp(),'XX')); |
| 44 |
|
| 45 |
|
| 46 |
new TestCase ( SECTION, "'qwe ert x\t\n 345654AB'.replace(new RegExp('x\\s*\\d+(..)$'),'****')", |
| 47 |
"qwe ert ****", 'qwe ert x\t\n 345654AB'.replace(new RegExp('x\\s*\\d+(..)$'),'****')); |
| 48 |
|
| 49 |
|
| 50 |
test(); |