trigram.js 1.0 KB

12345678910111213141516171819202122232425262728
  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. // The input is too small for trigram mega match to be done on it, so it should properly fall back to the regex engine
  6. var s = "GGCCGGGTAAAGTGGCTCACGCCTGTAATCCCAGCACTTTACCCCCCGAGGCGGGCGGA";
  7. writeLine(s.match(/[cgt]gggtaaa|tttaccc[acg]/ig));
  8. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  9. // Helpers
  10. var web;
  11. function writeLine(s) {
  12. if (web)
  13. document.writeln(s + "<br/>");
  14. else
  15. WScript.Echo("" + s);
  16. }
  17. function safeCall(f) {
  18. try {
  19. f();
  20. }
  21. catch (ex) {
  22. writeLine(ex.name + ": " + ex.message);
  23. }
  24. }