admin commited on
Commit
b7dc9f5
Β·
1 Parent(s): c38c77c

fix countWords

Browse files
Files changed (2) hide show
  1. index.html +2 -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
- String Len : <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>
 
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-9_]+/g) || [];
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