Spaces:
Running
Running
admin
commited on
Commit
Β·
b7dc9f5
1
Parent(s):
c38c77c
fix countWords
Browse files- index.html +2 -2
- js/main.js +1 -1
index.html
CHANGED
@@ -23,8 +23,8 @@
|
|
23 |
<div id="Tab2" class="tabcontent">
|
24 |
<h1>String β Length</h1>
|
25 |
<textarea rows="14"></textarea>
|
26 |
-
|
27 |
-
Word
|
28 |
</div>
|
29 |
<div id="Tab3" class="tabcontent">
|
30 |
<h1>Plaintext β MD5</h1>
|
|
|
23 |
<div id="Tab2" class="tabcontent">
|
24 |
<h1>String β Length</h1>
|
25 |
<textarea rows="14"></textarea>
|
26 |
+
Char count : <text id="len">0</text><br>
|
27 |
+
Word count : <text id="words">0</text>
|
28 |
</div>
|
29 |
<div id="Tab3" class="tabcontent">
|
30 |
<h1>Plaintext β MD5</h1>
|
js/main.js
CHANGED
@@ -43,7 +43,7 @@ function toBase64() {
|
|
43 |
}
|
44 |
|
45 |
function countWords(text) {
|
46 |
-
const words = text.match(/[a-zA-Z0-
|
47 |
return words.length;
|
48 |
}
|
49 |
|
|
|
43 |
}
|
44 |
|
45 |
function countWords(text) {
|
46 |
+
const words = text.match(/(\b[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*\b)|[a-zA-Z0-9]+/g) || [];
|
47 |
return words.length;
|
48 |
}
|
49 |
|