Poem Generator
https://editor.p5js.org/CodingMcnugget/sketches/rYck9xTvR
Using Javascript library english-words and regex, I repalced some word from O.Henry ’s famous paragraph
"Life is made up of sobs, sniffles, and smiles, with sniffles predominating. The most valuable gifts are those given from the heart. It's not about the price or rarity of the gift, but the love and sacrifice behind it. True love is measured by the willingness to give up something precious for the happiness of another."
Each time the script runs, sobs, smiles, price, rarity, secrifie, willingness and happiness will be repalce with a random word with same initial and length from english- word library.
ss = random(engWords.filter(word => /^s\\w{2}s$/.test(word)));
sss = random(engWords.filter(word => /^s\\w{4}s$/.test(word)));
ssss = random(engWords.filter(word => /^s\\w{6}$/.test(word)));
pp = random(engWords.filter(word => /^p\\w{4}$/.test(word)));
rr = random(engWords.filter(word => /^r\\w{2}ity$/.test(word)));
ww = random(engWords.filter(word => /^w\\w{6}ness$/.test(word)));
hh = random(engWords.filter(word => /^h\\w{4}ness$/.test(word)));
const regexPattern = "Life is made up of " + ss + ", sniffles, and " + sss+", with sniffles predominating\\\\. The most valuable gifts are those given from the heart\\\\. It's not about the " + ssss+" or "+pp+" of the gift, but the love and "+ssss+" behind it\\\\. True love is measured by the "+ww+" to give up something precious for the "+hh+" of another\\\\."