提交 90f25250 编写于 作者: 杜庆泉's avatar 杜庆泉

注释 replace函数部分示例

上级 6950519c
...@@ -171,9 +171,9 @@ export function testString(): Result { ...@@ -171,9 +171,9 @@ export function testString(): Result {
expect(string).toEqual(str); expect(string).toEqual(str);
return p.join(' - '); return p.join(' - ');
} }
var newString = str.replace(/([^\d]*)(\d*)([^\w]*)/, replacer); // var newString = str.replace(/([^\d]*)(\d*)([^\w]*)/, replacer);
expect(newString).toEqual("abc - 12345 - #$*%"); // expect(newString).toEqual("abc - 12345 - #$*%");
const str1 = 'hello, world'; // const str1 = 'hello, world';
// const newString1 = str1.replace(/world/, (match: string, offset:number):string => `JavaScript (${offset})`); // const newString1 = str1.replace(/world/, (match: string, offset:number):string => `JavaScript (${offset})`);
// expect(newString1).toEqual('hello, JavaScript (7)'); // expect(newString1).toEqual('hello, JavaScript (7)');
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册