Announcement

Collapse
No announcement yet.

help string find and count

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • help string find and count

    i have problem with string and table

    this scenario

    mytable = TextFile.ReadToTable("AutoPlay\\Docs\\test.log");
    patern = "name"

    string.find(mytable, patern, 1, false)
    if found then
    how many total patern found .
    this i do, but error code


    Code:
    mytable = TextFile.ReadToTable("AutoPlay\\Docs\\test.log");
    patern = "name"
    
    for i, v in pairs (mytable) do
            sFind = string.find (mytable,, patern, 1, false)
            if sFind ~= -1 then
               count = Table.Count(sFind);
               result = Dialog.Message("Notice", "Total : :"..count..", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
           end
    end
    help me please

  • #2
    i get solution in LUA forum

    Code:
    mytable = "AutoPlay\\Docs\\test.log"
    myString = TextFile.ReadToString(mytable);
    count = 0
    local patern = "name"
    for i in string.gfind(myString, patern) do
       count = count + 1
    end
    local _, count = string.gsub(myString, patern, "")
    result = Dialog.Message("Notice", "Total : :"..count..", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    may be useful for the other.
    there may be someone else who can provide solutions with different methods.

    Comment

    Working...
    X