I want to write a simple JavaScript that Counts the number of times a word ( or a set of characters) that are typed into input field appear in the textarea field.
Example: Imagine someone pastes a long paragraph into textarea, and wants to see how many times does the word "dog" or phrase "dog on the leash" appears in the text.
Condition:
<textarea id="txtarea" cols="30" rows="5"></textarea> <input type="text" id="input" cols="15" rows="1"></input>
Could someone please shed some light
var temp = "This is a dog, Dog."; console.log((temp.match(/dog/) || []).length);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.