lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Tue, 4 Jan 2005, Alex Sandro Queiroz e Silva wrote:

To find if the word contains a CamelCase string:

    function isCamelCase(str)
      return string.find(str,"%u%l+%u%l[%u%l]*")
    end

But wouldn't this pattern allow for AlexSaNDRO to be computed as a camel case word?

Absolutely. That doesn't violate the CamelCase rules I'm using for my LuaWiki, and I had forgotten that traditional CamelCase does not allow this. (In fact I've alterned mine to allow words like Jan2005 to be legal as well).

Given that, the best way to check is the way you did it. I don't have your original in my box anymore, so let me try to recreate it:

    function isCamelCase(str)
        local leftover,count = string.gsub(str,"%u%l+","")
        return count > 1 and string.len(leftover) == 0
    end

I think this is more or less what you had, and that works great. Sorry for the confusion.

A quick question: Are you using this to make a Wiki?

  - Tom


 twrensch@sdf.lonestar.org
SDF Public Access UNIX System - http://sdf.lonestar.org