lua-users home
lua-l archive

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

Joseph Stewart <> 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

which I think is roughly what I used when I wanted to match
WordsLikeThis without using a regular expression library.
Antony Sidwell.