lua-users home
lua-l archive

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


I need to delete all "\r" occurrences in a huge string (in other
words, I convert MS-Windows files to Unix). So I'm doing this:

    s:gsub("\r", "")

Now, just out of curiosity: gsub(), in contrast to find(), doesn't
have an argument that tells it "the pattern is plain substring". So my
question is:

(1) Is gsub() efficient when the pattern is "simple"? That is, where
the pattern doesn't contain "magic" characters?

But perhaps I should start with more elementary questions:

(2) Is s:find("b") as efficient as s:find("b", 1, true) ?
(3) Is s:find("%.") as efficient as s:find(".", 1, true) ?
(4) Can s:find("b") be considered "on par" with executing strstr(s, "b") in C?