regex.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. var re = /abc/i;
  11. var re1 = new RegExp(re, "gm");
  12. WScript.SetTimeout(testFunction, 50);
  13. /////////////////
  14. function testFunction()
  15. {
  16. telemetryLog(`re.global == ${re.global}`, true); //false
  17. telemetryLog(`re.multiline == ${re.multiline}`, true); //false
  18. telemetryLog(`re.ignoreCase == ${re.ignoreCase}`, true); //true
  19. telemetryLog(`re1.global == ${re1.global}`, true); //true
  20. telemetryLog(`re1.multiline == ${re1.multiline}`, true); //true
  21. telemetryLog(`re1.ignoreCase == ${re1.ignoreCase}`, true); //false
  22. telemetryLog(`y.lastIndex: ${y.lastIndex}`, true); //3
  23. telemetryLog(`z.lastIndex: ${z.lastIndex}`, true); //3
  24. ////
  25. var m = "Hello World".match(x);
  26. y.exec("Hello World");
  27. ////
  28. telemetryLog(`m.index: ${m.index}`, true); //6
  29. telemetryLog(`post update -- y.lastIndex: ${y.lastIndex}`, true); //4
  30. emitTTDLog(ttdLogURI);
  31. }