count word and space in text javascript
<html>
<body>
<script>
function countWords(str) {
str = str.replace(/(^\s*)|(\s*$)/gi,"");
str = str.replace(/[ ]{2,}/gi," ");
str = str.replace(/\n /,"\n");
return str.split(' ').length;
}
document.write(countWords(" Tutorix is one of the best E-learning platforms"));
</script>
</body>
</html><html>
<body>
<script>
function countWords(str) {
str = str.replace(/(^\s*)|(\s*$)/gi,"");
str = str.replace(/[ ]{2,}/gi," ");
str = str.replace(/\n /,"\n");
return str.split(' ').length;
}
document.write(countWords(" Tutorix is one of the best E-learning platforms"));
</script>
</body>
</html>
Also in JavaScript:
- node mailer office 365
- reactstrap search bar
- reference error $ is not defined jquery
- javascript insertBefore
- event listener javascript
- angular x social login
- node js express
- how to use await to console
- use ca certifcate node js
- get serialize data javascript
- active-class router-link
- node_modules/react-native-paper/lib/module/core/Provider.js
- jquery check if clicked outside div
- get selected value on componentdidmount reactjs
- angular vs react vs vue
- initialize a map js
- detect logged user wordpress javascript
- javascript convert string to bool
- js array sum
- disable copy past jquery
- remove a class after 100 milliseconds jquery
- create react app not creating template
- Given a string S and a character C, return an array of integers representing the shortest distance from the character C in the string. javascript
- click anchor tag using jquery