// function removeSpecialCharacters: removes punctuation marks and other special characters
// but allows numbers and alphabets along with language specific characters German: äöüÄÖÜß and French: ùûüÿàâæéèêëïîôœÙÛÜŸÀÂÆÉÈÊËÏÎÔŒ
functionremoveSpecialCharacters(str){
returnstr.replace(/(?!\w|\ä|\ö|\ü|\Ä|\Ö|\Ü|\ß|\ù|\û|\ü|\ÿ|\à|\â|\æ|\é|\è|\ê|\ë|\ï|\î|\ô|\œ|\Ù|\Û|\Ÿ|\À|\Â|\Æ|\É|\È|\Ê|\Ë|\Ï|\Î|\Ô|\Œ)./g,'')// regex to remove special characters
.replace(/^(\s*)([\W\w]*)(\b\s*$)/g,'$2');// regex to trim the string to remove any whitespace at the beginning or the end
}
...
...
@@ -123,18 +130,18 @@ function calculateReadingTime() {
console.log(inputObj);
// TODO: logic or algorithm for calculating reading time goes here
// inputObj.textLength has number of characters (number data type)
// inputObj.readerLevel has level of reader (number data type)
// inputObj.readerCategory has category of reader (number data type)
// inputObj.textLength has number of characters (number data type)
// inputObj.readerLevel has level of reader (number data type)
// inputObj.readerCategory has category of reader (number data type)