Quote: e That seem a clever way of making the periods match on the underlying text. Technically the period won't quite match correctly, you should probably replace "." by "%." before doing the string.match. Also the test for length 66 now becomes redundant, except to save a bit of speed, however the Lua pattern matching is very fast.
Perhaps if you did this:
str = string.gsub (str, ".", "%.") -- periods should match exactly
str = string.gsub (str, "*", ".") -- convert wildcards
str = "^" .. str .. "$" -- anchor it
Then you don't need the test for the length.
No that doesn't work because it doesn't catch things like misspelling a word.
If I do, as you posted and include:
Quote: str = string.gsub (str, ".", "%.")
It then ends up matching on a string like the following:
Quote: A prickly stinging ov*rcom*s your body, f*d*ng aw*y into nubbne*s.
"nubbness" is incorrect.
Just doing str = string.gsub(str, "*", ".") matches correctly and will flag nubbne*s as an illusion for misspell.
I'm just replacing the stars * with . which represents any single character so it matches with the regex pattern.
A prickly stinging ov*rcom*s your body, f*d*ng aw*y into nubbne*s.
turns into...
A prickly stinging ov.rcom.s your body, f.d.ng aw.y into nubbne.s.
and I am matching it against...
A prickly stinging overcomes your body, fading away into numbness.
which has a period at the end of it.
|