feat(facade): add RegExpWrapper.replaceAll to replace all matches using the provided function

This commit is contained in:
vsavkin
2016-03-23 13:41:18 -07:00
committed by Victor Savkin
parent aa966f5de2
commit 91999e016e
3 changed files with 35 additions and 0 deletions
@@ -42,6 +42,12 @@ export function main() {
// If not reset, the second attempt to test results in false
expect(RegExpWrapper.test(re, str)).toEqual(true);
});
it("should implement replace all", () => {
let re = /(\d)+/g;
let m = RegExpWrapper.replaceAll(re, 'a1b2c', (match) => `!${match[1]}!`);
expect(m).toEqual('a!1!b!2!c');
});
});
describe('const', () => {