Long sentences are long
-- false
Long words are long
-- true
Check to see if no word in this string is longer than 6 characters in a regex.
Most answers I've found online talk about checking the string length or a single word length.
Long sentences are long
-- false
Long words are long
-- true
Check to see if no word in this string is longer than 6 characters in a regex.
Most answers I've found online talk about checking the string length or a single word length.
What Tallboy said, but with a shorter Regex:
\S{6,}
Test Here
My Regex: 37 steps
Tallboy's Regex: 120 steps
It's probably easier to see if theres any words more than 6 and then reverse it with !
!/(^| )\w{6,}( |$)/.test("Long sentences are long")
!/(^| )\w{6,}( |$)/.test("Long words are long")