{"size": 1625, "ext": "js", "max_stars_repo_path": "ch9/regexpGolf.js", "max_stars_repo_name": "cthought14/eloqjs", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ch9/regexpGolf.js", "max_issues_repo_name": "cthought14/eloqjs", "max_issues_repo_issues_event_min_datetime": "2018-01-23T06:29:50.000Z", "max_issues_repo_issues_event_max_datetime": "2018-03-30T11:56:51.000Z", "max_forks_repo_path": "ch9/regexpGolf.js", "max_forks_repo_name": "cthought14/eloqjs", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 3, "max_forks_count": null, "avg_line_length": 25.7936507937, "max_line_length": 57, "alphanum_fraction": 0.5907692308}
// regexpGolf. Chapter 9, Exercise 1. Regexp golf.
"use strict";

function _tryRe(re, testString, testResult) {
    expect(re.test(testString), testResult);
}

var re;
console.log("1.");
re = /car|t/;
_tryRe(re, "a car and a", true);
_tryRe(re, "and a cat", true);
_tryRe(re, "a car and a cat", true);
_tryRe(re, "a cax and a caT", false);    

console.log("2.");
re = /pr?op/;
_tryRe(re, "a pop and a ", true);
_tryRe(re, "and a prop", true);
_tryRe(re, "a pop and a prop", true);
_tryRe(re, "a poop and a prom", false);

console.log("3.");
re = /ferret|ferry|ferrari/;
re = /ferr(et|y|ari)/;
_tryRe(re, "a ferret and a ", true);
_tryRe(re, "and a ferry", true);
_tryRe(re, "and a ferrari", true);
_tryRe(re, "a ferret and a ferry and a ferrari", true);
_tryRe(re, "a ferres and a ferri and a ferrary", false);

console.log("4.");
re = /\b.+ious\b/;
re = /ious\b/;
_tryRe(re, "delicious", true);
_tryRe(re, "deliciouss", false);
_tryRe(re, "delicous", false);

console.log("5.");
re = /\s[.,:;]/;
_tryRe(re, " .", true);
_tryRe(re, " ;", true);
_tryRe(re, "\n.", true);
_tryRe(re, "\t;", true);
_tryRe(re, ".", false);
_tryRe(re, ";", false);

console.log("6.");
re = /\w{7,}/;
_tryRe(re, "expeditious", true);
_tryRe(re, "  expeditious", true);
_tryRe(re, "adventure", true);
_tryRe(re, "  adventure", true);
_tryRe(re, "advent", false);
_tryRe(re, "  advent", false);

console.log("7.");
re = /\b[^e]+\b/;
_tryRe(re, ".eliminate", false);
_tryRe(re, "abate", false);
_tryRe(re, "..xylophonic..", true);
_tryRe(re, "the xylophonic elephant ate the eel", true);
