Difference between revisions of "String (API)"
From ComputerCraft Wiki
(→string.gmatch(string, pattern)) |
|||
Line 13: | Line 13: | ||
"abc=def":gmatch("%a.*") -- Works | "abc=def":gmatch("%a.*") -- Works | ||
"abc=def":gmatch("[%a.]*") -- Hang | "abc=def":gmatch("[%a.]*") -- Hang | ||
− | "abc=def":gmatch("[^=]*") -- Hang | + | "abc=def":gmatch("[^=]*") -- Hang - Alternative: "([^=]*)=?" |
"abcdef":gmatch("[^=]*") -- Works | "abcdef":gmatch("[^=]*") -- Works | ||
"abc=def":gmatch("[^=]*=") -- Works | "abc=def":gmatch("[^=]*=") -- Works |
Revision as of 15:40, 19 April 2012
The string API is a default Lua 5.1 API as defined here. Please list any non-working functions below.
Non-Working Functions
string.gmatch(string, pattern)
Using any quantifier other than + will cause it to hang if that quantifier applies to the whole pattern and that pattern does not match the whole string.
Examples:
"abcdef":gmatch("%a*") -- Works "abc=def":gmatch("%a*") -- Hang "abc=def":gmatch("%a.*") -- Works "abc=def":gmatch("[%a.]*") -- Hang "abc=def":gmatch("[^=]*") -- Hang - Alternative: "([^=]*)=?" "abcdef":gmatch("[^=]*") -- Works "abc=def":gmatch("[^=]*=") -- Works