[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Testing for CamelCase
- From: Alex Sandro Queiroz e Silva <ventonegro@...>
- Date: Mon, 03 Jan 2005 17:56:47 -0300
Hallo guys,
I've written the following function to test if a string is in camel
case, because Lua patterns don't support modifiers on groupings. It
works, but as I have little experience with text processing in Lua, I am
posting it here to see if someone comes up with a better solution. Thanks!
-- checks if a string is in CamelCase
function isCamelCase(str)
local count = 0
local s = string.gsub(str, "(%u%l+)",
function(n) count = count + 1 return "" end)
if count < 2 or s ~= "" then
return nil
else
return not nil
end
end
-alex