regex.js 927 B

1234567891011121314151617181920212223242526272829
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. var x = /World/;
  6. var y = new RegExp("l", "g");
  7. var z = new RegExp("l", "g");
  8. y.exec("Hello World");
  9. z.lastIndex = -1;
  10. WScript.SetTimeout(testFunction, 50);
  11. /////////////////
  12. function testFunction()
  13. {
  14. telemetryLog(`y.lastIndex: ${y.lastIndex}`, true); //3
  15. telemetryLog(`z.lastIndex: ${z.lastIndex}`, true); //3
  16. ////
  17. var m = "Hello World".match(x);
  18. y.exec("Hello World");
  19. ////
  20. telemetryLog(`m.index: ${m.index}`, true); //6
  21. telemetryLog(`post update -- y.lastIndex: ${y.lastIndex}`, true); //4
  22. }