Skip to content

Instantly share code, notes, and snippets.

@nyanpasu64
Last active November 21, 2016 06:22
Show Gist options
  • Select an option

  • Save nyanpasu64/6bef6850d1fe2b3cfa7eb442d0537ab5 to your computer and use it in GitHub Desktop.

Select an option

Save nyanpasu64/6bef6850d1fe2b3cfa7eb442d0537ab5 to your computer and use it in GitHub Desktop.
University of California - An excellent word count system
var numInstancesCRLFs = countInstances(inputText, '\r\n');
if (numInstancesCRLFs > 0) {
padLengthBy = numInstancesCRLFs * 4;
charCounter = charCounter + padLengthBy;
}
else {
var numInstancesLFCRs = countInstances(inputText, '\n\r');
if (numInstancesLFCRs > 0) {
padLengthBy = numInstancesLFCRs * 4;
charCounter = charCounter + padLengthBy;
} else {
var numInstancesCRs = countInstances(inputText, '\r');
if (numInstancesCRs > 0) {
padLengthBy = numInstancesCRs * 4;
charCounter = charCounter + padLengthBy;
} else {
var numInstancesLFs = countInstances(inputText, '\n');
if (numInstancesLFs > 0) {
padLengthBy = numInstancesLFs * 4;
charCounter = charCounter + padLengthBy;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment