-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path00_CountWord-Sentence.html
More file actions
45 lines (39 loc) · 1.05 KB
/
00_CountWord-Sentence.html
File metadata and controls
45 lines (39 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Text Analysis</title>
<style>
textarea {
width: 100%;
height: 200px;
resize: none;
margin-bottom: 10px;
}
</style>
</head>
<body>
<textarea id="textInput" placeholder="Enter your text here..."></textarea>
<button onclick="analyzeText()">Submit</button>
<div id="report"></div>
<script>
function analyzeText() {
var text = document.getElementById('textInput').value;
// Counting sentences
var sentences = text.split(/[.!?]+/).length - 1;
// Counting words
var words = text.match(/\w+/g).length;
// Counting lines
var lines = text.split(/\r\n|\r|\n/).length;
// Displaying the report
var report = document.getElementById('report');
report.innerHTML = `
<p>Total Sentences: ${sentences}</p>
<p>Total Words: ${words}</p>
<p>Total Lines: ${lines}</p>
`;
}
</script>
</body>
</html>