I'm writing a script in JS which will be used for generating a Complete the sentence type of quiz.
The _______ brown fox jumps over the lazy _____.
Step 1: The user will be presented with a textbox to put a sentence in.
Step 2: The sentence will be broken up into actual words(no commas, full stops etc) into an array.
Step 3: In the background, I'll loop through each of the words and wrap them in an anchor <a />
Step 4: The user will be able to click on one or many words to mark them for the quiz taker to complete. I will do some validation around this.
Step 5: The end result will be a sentence with blank spaces for the words that were selected with a random number (1-n) of extra characters so there's no exact hints for the words length.
Most of the functionality I'm ok with, but I need to split the sentence into exact words (presumably using regex).
There are a few rules around this, commas and full stops should be ignored as well as any special characters. I'm also thinking of limiting the input so that special characters aren't allowed to make this an easier task. Single quotes and hyphens should be included in the word matching as some words contain these.
There may be other rules I can't think of so very happy for you to leave a comment and suggest them.
I have started with a basic jsFiddle which simply separates by spaces.
Thanks for reading.