Require a word (including its subscript) to end in a number or letter.
authorMatthijs Kooijman <matthijs@stdin.nl>
Wed, 9 Dec 2009 11:49:53 +0000 (12:49 +0100)
committerMatthijs Kooijman <matthijs@stdin.nl>
Wed, 9 Dec 2009 11:49:53 +0000 (12:49 +0100)
pret-lam.lua

index 88e39246772b02766cd5580312f92f65b3763dca..feaa5e43934cbb157757b9152c38a6ea8f624c72 100644 (file)
@@ -88,8 +88,12 @@ end
 -- the word taken.
 local function take_word(str)
         -- A word must always start with a-z (in particular, λ is not a valid
 -- the word taken.
 local function take_word(str)
         -- A word must always start with a-z (in particular, λ is not a valid
-        -- start of a word).
-        res, newstr = utf.match(str, "^([a-zA-Z][%a%d%+%-%,_]+)(.*)")
+        -- start of a word). A word must always end with a letter or a digit
+        res, newstr = utf.match(str, "^([a-zA-Z][%a%d%+%-%,_]*[%a%d]+)(.*)")
+        if not res then
+            -- The above does not catch single letter words
+            res, newstr = utf.match(str, "^([a-zA-Z])(.*)")
+        end
         return res, newstr or str
 end
 
         return res, newstr or str
 end