lua-users home
lua-l archive

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


"^%u%l+%u%l%a*$" does a slightly better job of filtering but it still needs
the secondary filter against double uppercase letters in the case of strings
with 3 or more uppercase letters. The combination of those two filters,
however, should give you everything you need.

Mark

on 6/26/04 4:10 AM, Antony Sidwell at antony@isparp.co.uk wrote:

> Joseph Stewart <joseph.stewart@gmail.com> wrote:
> 
>> Can anyone suggest a pattern to match text in the following format:
>> 
>> Must start with a upper-case letter.
>> Must be followed by one or more lower-case letter.
>> Above conditions must repeat at least one time (but could be many).
> 
> %u%l+%u%a+ is more or less as close as you can get using a simple
> pattern, which will match "ThisMAtchesWrongly" as well.  Otherwise
> you're into a regex library or a bit more code, e.g.
> 
> if string.find(s, "^%u%l+%u%a+$") and not string.find(s, "%u%u") then
> -- do stuff
> end
> 
> which I think is roughly what I used when I wanted to match
> WordsLikeThis without using a regular expression library.