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

注释掉部分 string.replace 测试示例

上级 15d44ba9
......@@ -189,13 +189,14 @@ export function testString(): Result {
return p.join(' - ');
}
const REGEX_FORMAT = /[YMDHhms]o|\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a{1,2}|A{1,2}|m{1,2}|s{1,2}|Z{1,2}|SSS/g
const formatStr = 'This is a [sample] text with [another] capture group.'
const nextStr = formatStr.replace(REGEX_FORMAT, (match:string, p1: string|null, offset: number, string: string):string =>{
console.log('123', p1, match)
return p1 ?? match ?? ''
})
expect(nextStr).toEqual('This is a sample text with another capture group.');
// const REGEX_FORMAT = /[YMDHhms]o|\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a{1,2}|A{1,2}|m{1,2}|s{1,2}|Z{1,2}|SSS/g
// const formatStr = 'This is a [sample] text with [another] capture group.'
// const nextStr = formatStr.replace(REGEX_FORMAT, (match:string, p1: string|null, offset: number, string: string):string =>{
// console.log('123', p1, match)
// return p1 ?? match ?? ''
// })
// expect(nextStr).toEqual('This is a sample text with another capture group.');
// var newString = str.replace(/([^\d]*)(\d*)([^\w]*)/, replacer);
// expect(newString).toEqual("abc - 12345 - #$*%");
// const str1 = 'hello, world';
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册