lua-users home
lua-l archive

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


I'm trying to understand this error. I tried looking at the source, but it didn't help much. I'm getting this error as the result of looking for a word in a localized string.

I'm originally given a string similar to: "%s goes to %s". This is localized during startup, and it is formatted according to the situation. I receive the formatted string and would like to extract what each %s is. Thus I'm using captures. So I take "%s goes to %s" and format it:

local x = "Dave goes to Britain" -- Given to me

local y = string.format("%s goes to %s", "(%w*)", "(%w*)");

-- Then I get the captures:

local _, _, who, where = string.find(x, y);

print(who)
print(where)

My problem is this works fine for English, but when I use this for a German locale I receive the error: Invalid Capture Index. I'm really confused about what is going wrong here, mostly because I don't understand this error.

-Patrick Donnelly

"One of the lessons of history is that nothing is often a good thing to do and always a clever thing to say."

-Will Durant