Difference between revisions of "String (API)"
Tomass1996 (Talk | contribs) (Undo revision 4668 by 85.172.4.154 (talk)) |
(→string.gmatch(string, pattern)) |
||
Line 3: | Line 3: | ||
==Non-Working Functions== | ==Non-Working Functions== | ||
− | + | 其實不需要動到 filter,sql 語法只要用:cQry := SELECT * FROM xxx WHERE ABC=:ABC AND CCC=:CCC';myQuery1.SQL.Text := cQry;myQuery1.ParamByName( ABC').AsString := test';myQuery1.ParamByName( CCC').AsString := QQQ';myQuery1.Open;這樣子也可以喔! | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
===string.sub / string.find === | ===string.sub / string.find === |
Revision as of 04:41, 5 December 2012
The string API is a default Lua 5.1 API as defined here. Please list any non-working functions below.
Non-Working Functions
其實不需要動到 filter,sql 語法只要用:cQry := SELECT * FROM xxx WHERE ABC=:ABC AND CCC=:CCC';myQuery1.SQL.Text := cQry;myQuery1.ParamByName( ABC').AsString := test';myQuery1.ParamByName( CCC').AsString := QQQ';myQuery1.Open;這樣子也可以喔!
string.sub / string.find
Both string.sub and string.find work on their own, but calling string.find on a string returned by string.sub will return the index of the character in the original string, not the sub string you are referencing.
Example:
local testString = "This is a sample string"; local testSubString = string.sub(testString,5); local indexOfSample = string.find(testSubString,"sample");
indexOfSample is returned 11 instead of the expected 7
Concatenating a blank string onto the end of the string causes new memory to be allocated and works properly again
local testString = "This is a sample string"; local testSubString = string.sub(testString,5); local indexOfSample = string.find(testSubString.."","sample");
This is also a problem with using string.find on command line arguments, as this returns the index in the full command path instead of the specific argument.