Skip to content

Instantly share code, notes, and snippets.

@jcsalterego
Last active June 6, 2023 19:28
Show Gist options
  • Save jcsalterego/bdf5f5f163170c3b98841e61586f7c46 to your computer and use it in GitHub Desktop.
Save jcsalterego/bdf5f5f163170c3b98841e61586f7c46 to your computer and use it in GitHub Desktop.
function hasDotNet(text) {
return text.match(/.NET|[\s^]\.net/) !== null;
}
function test(expected, text) {
let rv = hasDotNet(text);
if (expected !== rv) {
console.log(`expected ${expected}, but got ${rv} = ${text}`);
} else {
console.log(`✅ ${rv} = ${text}`);
}
}
test(true, "i love .net");
test(true, "i love .NET");
test(false, "i dislike viruses.net");
node dotnet.js
✅ true = i love .net
✅ true = i love .NET
✅ false = i dislike viruses.net
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment