Created
September 23, 2013 23:49
-
-
Save brianfryer/6678569 to your computer and use it in GitHub Desktop.
This script is capable of parsing a snapnames text file to create a new text file that contains a list of domain names 6 characters in length or less.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get access to the file system | |
fs = require('fs'); | |
// Grab the text file | |
var lines = fs.readFileSync('./snapnames.txt', 'utf8') | |
.replace(/([^\dA-z\.\-])+(\s+\S+\s+)/g, ',') // trim the file | |
.split(','), // make it into an array | |
domains = []; | |
// Parse each item in the array | |
for (i = 0; i < lines.length; i++) { | |
// Exclude the TLD | |
var domainName = lines[i].split('.'); | |
// If the domain's length is less than 6 characters... | |
if (domainName[0].length <= 6) { | |
// ...add it to the `domains` array | |
domains.push(lines[i]); | |
} | |
} | |
// Return a list of domain names that are less than 6 characters long | |
fs.writeFileSync('./snapnames-lessthan5.txt', domains.join('\n')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment