|
> It is tricky to capture the longest valid Lua identifier from the start of
> a string.
>
> - The pattern "^([%a_][%w_]*)" is locale-dependent.
>
> - The pattern "^([A-Za-Z_][A-Za-Z0-9_]*)" works only with the original
> lctype.c.
>
> [...]
>
> Any better ideas?
1) Spell it out:
[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_][abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0-9]*
2) do os.setlocale("C") before the match.
3) Ignore EBCDIC and assume that [A-Za-Z_] matches all letters.
-- Roberto